() {{
11 | put("limit", "2");
12 | put("offset", "0");
13 | }});
14 | System.out.println(result2);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/rest/js/README.md:
--------------------------------------------------------------------------------
1 | https://www.npmjs.com/package/crypto-js
2 | bower install crypto-js
3 |
4 | http://jquery.com/
5 | bower install jquery
6 |
7 |
--------------------------------------------------------------------------------
/rest/js/jquery_version.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Exmo API jquery
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/rest/js/native_js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Exmo API
6 |
7 |
8 |
9 |
10 |
11 |
68 |
69 |
--------------------------------------------------------------------------------
/rest/js/native_js_promise.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Exmo API
6 |
7 |
8 |
9 |
10 |
11 |
91 |
92 |
--------------------------------------------------------------------------------
/rest/js/server.bat:
--------------------------------------------------------------------------------
1 | node web-server.js
2 | PAUSE
--------------------------------------------------------------------------------
/rest/js/web-server.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var util = require('util'),
4 | http = require('http'),
5 | fs = require('fs'),
6 | url = require('url'),
7 | events = require('events');
8 |
9 | var DEFAULT_PORT = 8000;
10 |
11 | function main(argv) {
12 | new HttpServer({
13 | 'GET': createServlet(StaticServlet),
14 | 'HEAD': createServlet(StaticServlet)
15 | }).start(Number(argv[2]) || DEFAULT_PORT);
16 | }
17 |
18 | function escapeHtml(value) {
19 | return value.toString().
20 | replace('<', '<').
21 | replace('>', '>').
22 | replace('"', '"');
23 | }
24 |
25 | function createServlet(Class) {
26 | var servlet = new Class();
27 | return servlet.handleRequest.bind(servlet);
28 | }
29 |
30 | /**
31 | * An Http server implementation that uses a map of methods to decide
32 | * action routing.
33 | *
34 | * @param {Object} Map of method => Handler function
35 | */
36 | function HttpServer(handlers) {
37 | this.handlers = handlers;
38 | this.server = http.createServer(this.handleRequest_.bind(this));
39 | }
40 |
41 | HttpServer.prototype.start = function(port) {
42 | this.port = port;
43 | this.server.listen(port);
44 | util.puts('Http Server running at http://localhost:' + port + '/');
45 | };
46 |
47 | HttpServer.prototype.parseUrl_ = function(urlString) {
48 | var parsed = url.parse(urlString);
49 | parsed.pathname = url.resolve('/', parsed.pathname);
50 | return url.parse(url.format(parsed), true);
51 | };
52 |
53 | HttpServer.prototype.handleRequest_ = function(req, res) {
54 | var logEntry = req.method + ' ' + req.url;
55 | if (req.headers['user-agent']) {
56 | logEntry += ' ' + req.headers['user-agent'];
57 | }
58 | util.puts(logEntry);
59 | req.url = this.parseUrl_(req.url);
60 | var handler = this.handlers[req.method];
61 | if (!handler) {
62 | res.writeHead(501);
63 | res.end();
64 | } else {
65 | handler.call(this, req, res);
66 | }
67 | };
68 |
69 | /**
70 | * Handles static content.
71 | */
72 | function StaticServlet() {}
73 |
74 | StaticServlet.MimeMap = {
75 | 'txt': 'text/plain',
76 | 'html': 'text/html',
77 | 'css': 'text/css',
78 | 'xml': 'application/xml',
79 | 'json': 'application/json',
80 | 'js': 'application/javascript',
81 | 'jpg': 'image/jpeg',
82 | 'jpeg': 'image/jpeg',
83 | 'gif': 'image/gif',
84 | 'png': 'image/png',
85 | 'svg': 'image/svg+xml'
86 | };
87 |
88 | StaticServlet.prototype.handleRequest = function(req, res) {
89 | var self = this;
90 | var path = ('./' + req.url.pathname).replace('//','/').replace(/%(..)/g, function(match, hex){
91 | return String.fromCharCode(parseInt(hex, 16));
92 | });
93 | var parts = path.split('/');
94 | if (parts[parts.length-1].charAt(0) === '.')
95 | return self.sendForbidden_(req, res, path);
96 | fs.stat(path, function(err, stat) {
97 | if (err)
98 | return self.sendMissing_(req, res, path);
99 | if (stat.isDirectory())
100 | return self.sendDirectory_(req, res, path);
101 | return self.sendFile_(req, res, path);
102 | });
103 | }
104 |
105 | StaticServlet.prototype.sendError_ = function(req, res, error) {
106 | res.writeHead(500, {
107 | 'Content-Type': 'text/html'
108 | });
109 | res.write('\n');
110 | res.write('Internal Server Error\n');
111 | res.write('Internal Server Error
');
112 | res.write('' + escapeHtml(util.inspect(error)) + '
');
113 | util.puts('500 Internal Server Error');
114 | util.puts(util.inspect(error));
115 | };
116 |
117 | StaticServlet.prototype.sendMissing_ = function(req, res, path) {
118 | path = path.substring(1);
119 | res.writeHead(404, {
120 | 'Content-Type': 'text/html'
121 | });
122 | res.write('\n');
123 | res.write('404 Not Found\n');
124 | res.write('Not Found
');
125 | res.write(
126 | 'The requested URL ' +
127 | escapeHtml(path) +
128 | ' was not found on this server.
'
129 | );
130 | res.end();
131 | util.puts('404 Not Found: ' + path);
132 | };
133 |
134 | StaticServlet.prototype.sendForbidden_ = function(req, res, path) {
135 | path = path.substring(1);
136 | res.writeHead(403, {
137 | 'Content-Type': 'text/html'
138 | });
139 | res.write('\n');
140 | res.write('403 Forbidden\n');
141 | res.write('Forbidden
');
142 | res.write(
143 | 'You do not have permission to access ' +
144 | escapeHtml(path) + ' on this server.
'
145 | );
146 | res.end();
147 | util.puts('403 Forbidden: ' + path);
148 | };
149 |
150 | StaticServlet.prototype.sendRedirect_ = function(req, res, redirectUrl) {
151 | res.writeHead(301, {
152 | 'Content-Type': 'text/html',
153 | 'Location': redirectUrl
154 | });
155 | res.write('\n');
156 | res.write('301 Moved Permanently\n');
157 | res.write('Moved Permanently
');
158 | res.write(
159 | 'The document has moved here.
'
162 | );
163 | res.end();
164 | util.puts('301 Moved Permanently: ' + redirectUrl);
165 | };
166 |
167 | StaticServlet.prototype.sendFile_ = function(req, res, path) {
168 | var self = this;
169 | var file = fs.createReadStream(path);
170 | res.writeHead(200, {
171 | 'Content-Type': StaticServlet.
172 | MimeMap[path.split('.').pop()] || 'text/plain'
173 | });
174 | if (req.method === 'HEAD') {
175 | res.end();
176 | } else {
177 | file.on('data', res.write.bind(res));
178 | file.on('close', function() {
179 | res.end();
180 | });
181 | file.on('error', function(error) {
182 | self.sendError_(req, res, error);
183 | });
184 | }
185 | };
186 |
187 | StaticServlet.prototype.sendDirectory_ = function(req, res, path) {
188 | var self = this;
189 | if (path.match(/[^\/]$/)) {
190 | req.url.pathname += '/';
191 | var redirectUrl = url.format(url.parse(url.format(req.url)));
192 | return self.sendRedirect_(req, res, redirectUrl);
193 | }
194 | fs.readdir(path, function(err, files) {
195 | if (err)
196 | return self.sendError_(req, res, error);
197 |
198 | if (!files.length)
199 | return self.writeDirectoryIndex_(req, res, path, []);
200 |
201 | var remaining = files.length;
202 | files.forEach(function(fileName, index) {
203 | fs.stat(path + '/' + fileName, function(err, stat) {
204 | if (err)
205 | return self.sendError_(req, res, err);
206 | if (stat.isDirectory()) {
207 | files[index] = fileName + '/';
208 | }
209 | if (!(--remaining))
210 | return self.writeDirectoryIndex_(req, res, path, files);
211 | });
212 | });
213 | });
214 | };
215 |
216 | StaticServlet.prototype.writeDirectoryIndex_ = function(req, res, path, files) {
217 | path = path.substring(1);
218 | res.writeHead(200, {
219 | 'Content-Type': 'text/html'
220 | });
221 | if (req.method === 'HEAD') {
222 | res.end();
223 | return;
224 | }
225 | res.write('\n');
226 | res.write('' + escapeHtml(path) + '\n');
227 | res.write('\n');
230 | res.write('Directory: ' + escapeHtml(path) + '
');
231 | res.write('');
232 | files.forEach(function(fileName) {
233 | if (fileName.charAt(0) !== '.') {
234 | res.write('- ' +
236 | escapeHtml(fileName) + '
');
237 | }
238 | });
239 | res.write('
');
240 | res.end();
241 | };
242 |
243 | // Must be last,
244 | main(process.argv);
245 |
--------------------------------------------------------------------------------
/rest/nodejs/README.md:
--------------------------------------------------------------------------------
1 | https://www.npmjs.com/package/crypto-js
2 | npm install crypto-js
3 |
4 | https://www.npmjs.com/package/querystring
5 | npm install querystring
6 |
7 | https://www.npmjs.com/package/request
8 | npm install request
9 |
--------------------------------------------------------------------------------
/rest/nodejs/exmo.js:
--------------------------------------------------------------------------------
1 | var crypto = require('crypto')
2 | http = require('http'),
3 | querystring = require('querystring'),
4 | request = require('request'),
5 | config = {
6 | url: 'https://api.exmo.com/v1/'
7 | };
8 |
9 |
10 | function sign(message){
11 | return crypto.createHmac('sha512', config.secret).update(message).digest('hex');
12 | }
13 |
14 | exports.init_exmo = function (cfg) {
15 | config.key = cfg.key;
16 | config.secret = cfg.secret;
17 | config.nonce = Math.floor(new Date().getTime());
18 | };
19 |
20 | exports.api_query = function(method_name, data, callback){
21 | data.nonce = config.nonce++;
22 | var post_data = querystring.stringify(data);
23 |
24 | var options = {
25 | url: config.url + method_name,
26 | method: 'POST',
27 | headers: {
28 | 'Key': config.key,
29 | 'Sign': sign(post_data)
30 | },
31 | form:data
32 | };
33 |
34 | request(options, function (error, response, body) {
35 | if (!error && response.statusCode == 200) {
36 | callback(body);
37 | }else{
38 | callback(error);
39 | }
40 | });
41 | };
42 |
43 | exports.api_query2 = function(method_name, data, callback){
44 | data.nonce = config.nonce++;
45 | var post_data = querystring.stringify(data);
46 |
47 | var post_options = {
48 | host: 'api.exmo.com',
49 | port: '80',
50 | path: '/v1/' + method_name,
51 | method: 'POST',
52 | headers: {
53 | 'Key': config.key,
54 | 'Sign': sign(post_data),
55 | 'Content-Type': 'application/x-www-form-urlencoded',
56 | 'Content-Length': Buffer.byteLength(post_data)
57 | }
58 | };
59 | var post_req = http.request(post_options, function(res) {
60 | res.setEncoding('utf8');
61 | res.on('data', function (chunk) {
62 | callback(chunk);
63 | });
64 | });
65 |
66 | post_req.write(post_data);
67 | post_req.end();
68 | };
69 |
70 |
71 |
72 | exports.test = function(){
73 | return config.key;
74 | };
75 |
--------------------------------------------------------------------------------
/rest/nodejs/test_exmo.js:
--------------------------------------------------------------------------------
1 | var exmo = require("./exmo");
2 |
3 | exmo.init_exmo({key:'your_key', secret:'your_secret'});
4 | //request version
5 | exmo.api_query("user_info", { }, function(result){
6 | console.log(result);
7 | exmo.api_query("user_cancelled_orders", { "limit":1, "offset":0 }, function(result){
8 | console.log(result);
9 |
10 | //http nodejs version
11 | exmo.api_query2("user_info", { }, function(result){
12 | console.log(result);
13 | exmo.api_query2("user_cancelled_orders", { "limit":2, "offset":0 }, function(result){
14 | console.log(result);
15 | });
16 | });
17 | });
18 |
19 | });
20 |
--------------------------------------------------------------------------------
/rest/objectivec/api.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 84BFEEA71C70827F009C9544 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BFEEA61C70827F009C9544 /* main.m */; };
11 | 84BFEEAF1C7084A8009C9544 /* ExmoApiHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BFEEAE1C7084A8009C9544 /* ExmoApiHandler.m */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 84BFEEA11C70827F009C9544 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | );
22 | runOnlyForDeploymentPostprocessing = 1;
23 | };
24 | /* End PBXCopyFilesBuildPhase section */
25 |
26 | /* Begin PBXFileReference section */
27 | 84BFEEA31C70827F009C9544 /* api */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = api; sourceTree = BUILT_PRODUCTS_DIR; };
28 | 84BFEEA61C70827F009C9544 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
29 | 84BFEEAD1C7084A0009C9544 /* ExmoApiHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExmoApiHandler.h; sourceTree = ""; };
30 | 84BFEEAE1C7084A8009C9544 /* ExmoApiHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExmoApiHandler.m; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 84BFEEA01C70827F009C9544 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 84BFEE9A1C70827F009C9544 = {
45 | isa = PBXGroup;
46 | children = (
47 | 84BFEEA51C70827F009C9544 /* api */,
48 | 84BFEEA41C70827F009C9544 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 84BFEEA41C70827F009C9544 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 84BFEEA31C70827F009C9544 /* api */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 84BFEEA51C70827F009C9544 /* api */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 84BFEEAE1C7084A8009C9544 /* ExmoApiHandler.m */,
64 | 84BFEEAD1C7084A0009C9544 /* ExmoApiHandler.h */,
65 | 84BFEEA61C70827F009C9544 /* main.m */,
66 | );
67 | path = api;
68 | sourceTree = "";
69 | };
70 | /* End PBXGroup section */
71 |
72 | /* Begin PBXNativeTarget section */
73 | 84BFEEA21C70827F009C9544 /* api */ = {
74 | isa = PBXNativeTarget;
75 | buildConfigurationList = 84BFEEAA1C70827F009C9544 /* Build configuration list for PBXNativeTarget "api" */;
76 | buildPhases = (
77 | 84BFEE9F1C70827F009C9544 /* Sources */,
78 | 84BFEEA01C70827F009C9544 /* Frameworks */,
79 | 84BFEEA11C70827F009C9544 /* CopyFiles */,
80 | );
81 | buildRules = (
82 | );
83 | dependencies = (
84 | );
85 | name = api;
86 | productName = api;
87 | productReference = 84BFEEA31C70827F009C9544 /* api */;
88 | productType = "com.apple.product-type.tool";
89 | };
90 | /* End PBXNativeTarget section */
91 |
92 | /* Begin PBXProject section */
93 | 84BFEE9B1C70827F009C9544 /* Project object */ = {
94 | isa = PBXProject;
95 | attributes = {
96 | LastUpgradeCheck = 0720;
97 | ORGANIZATIONNAME = exmo;
98 | TargetAttributes = {
99 | 84BFEEA21C70827F009C9544 = {
100 | CreatedOnToolsVersion = 7.2.1;
101 | };
102 | };
103 | };
104 | buildConfigurationList = 84BFEE9E1C70827F009C9544 /* Build configuration list for PBXProject "api" */;
105 | compatibilityVersion = "Xcode 3.2";
106 | developmentRegion = English;
107 | hasScannedForEncodings = 0;
108 | knownRegions = (
109 | en,
110 | );
111 | mainGroup = 84BFEE9A1C70827F009C9544;
112 | productRefGroup = 84BFEEA41C70827F009C9544 /* Products */;
113 | projectDirPath = "";
114 | projectRoot = "";
115 | targets = (
116 | 84BFEEA21C70827F009C9544 /* api */,
117 | );
118 | };
119 | /* End PBXProject section */
120 |
121 | /* Begin PBXSourcesBuildPhase section */
122 | 84BFEE9F1C70827F009C9544 /* Sources */ = {
123 | isa = PBXSourcesBuildPhase;
124 | buildActionMask = 2147483647;
125 | files = (
126 | 84BFEEA71C70827F009C9544 /* main.m in Sources */,
127 | 84BFEEAF1C7084A8009C9544 /* ExmoApiHandler.m in Sources */,
128 | );
129 | runOnlyForDeploymentPostprocessing = 0;
130 | };
131 | /* End PBXSourcesBuildPhase section */
132 |
133 | /* Begin XCBuildConfiguration section */
134 | 84BFEEA81C70827F009C9544 /* Debug */ = {
135 | isa = XCBuildConfiguration;
136 | buildSettings = {
137 | ALWAYS_SEARCH_USER_PATHS = NO;
138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139 | CLANG_CXX_LIBRARY = "libc++";
140 | CLANG_ENABLE_MODULES = YES;
141 | CLANG_ENABLE_OBJC_ARC = YES;
142 | CLANG_WARN_BOOL_CONVERSION = YES;
143 | CLANG_WARN_CONSTANT_CONVERSION = YES;
144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
145 | CLANG_WARN_EMPTY_BODY = YES;
146 | CLANG_WARN_ENUM_CONVERSION = YES;
147 | CLANG_WARN_INT_CONVERSION = YES;
148 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
149 | CLANG_WARN_UNREACHABLE_CODE = YES;
150 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
151 | CODE_SIGN_IDENTITY = "-";
152 | COPY_PHASE_STRIP = NO;
153 | DEBUG_INFORMATION_FORMAT = dwarf;
154 | ENABLE_STRICT_OBJC_MSGSEND = YES;
155 | ENABLE_TESTABILITY = YES;
156 | GCC_C_LANGUAGE_STANDARD = gnu99;
157 | GCC_DYNAMIC_NO_PIC = NO;
158 | GCC_NO_COMMON_BLOCKS = YES;
159 | GCC_OPTIMIZATION_LEVEL = 0;
160 | GCC_PREPROCESSOR_DEFINITIONS = (
161 | "DEBUG=1",
162 | "$(inherited)",
163 | );
164 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
165 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
166 | GCC_WARN_UNDECLARED_SELECTOR = YES;
167 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
168 | GCC_WARN_UNUSED_FUNCTION = YES;
169 | GCC_WARN_UNUSED_VARIABLE = YES;
170 | MACOSX_DEPLOYMENT_TARGET = 10.11;
171 | MTL_ENABLE_DEBUG_INFO = YES;
172 | ONLY_ACTIVE_ARCH = YES;
173 | SDKROOT = macosx;
174 | };
175 | name = Debug;
176 | };
177 | 84BFEEA91C70827F009C9544 /* Release */ = {
178 | isa = XCBuildConfiguration;
179 | buildSettings = {
180 | ALWAYS_SEARCH_USER_PATHS = NO;
181 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
182 | CLANG_CXX_LIBRARY = "libc++";
183 | CLANG_ENABLE_MODULES = YES;
184 | CLANG_ENABLE_OBJC_ARC = YES;
185 | CLANG_WARN_BOOL_CONVERSION = YES;
186 | CLANG_WARN_CONSTANT_CONVERSION = YES;
187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188 | CLANG_WARN_EMPTY_BODY = YES;
189 | CLANG_WARN_ENUM_CONVERSION = YES;
190 | CLANG_WARN_INT_CONVERSION = YES;
191 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
192 | CLANG_WARN_UNREACHABLE_CODE = YES;
193 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
194 | CODE_SIGN_IDENTITY = "-";
195 | COPY_PHASE_STRIP = NO;
196 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
197 | ENABLE_NS_ASSERTIONS = NO;
198 | ENABLE_STRICT_OBJC_MSGSEND = YES;
199 | GCC_C_LANGUAGE_STANDARD = gnu99;
200 | GCC_NO_COMMON_BLOCKS = YES;
201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
203 | GCC_WARN_UNDECLARED_SELECTOR = YES;
204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
205 | GCC_WARN_UNUSED_FUNCTION = YES;
206 | GCC_WARN_UNUSED_VARIABLE = YES;
207 | MACOSX_DEPLOYMENT_TARGET = 10.11;
208 | MTL_ENABLE_DEBUG_INFO = NO;
209 | SDKROOT = macosx;
210 | };
211 | name = Release;
212 | };
213 | 84BFEEAB1C70827F009C9544 /* Debug */ = {
214 | isa = XCBuildConfiguration;
215 | buildSettings = {
216 | PRODUCT_NAME = "$(TARGET_NAME)";
217 | };
218 | name = Debug;
219 | };
220 | 84BFEEAC1C70827F009C9544 /* Release */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | PRODUCT_NAME = "$(TARGET_NAME)";
224 | };
225 | name = Release;
226 | };
227 | /* End XCBuildConfiguration section */
228 |
229 | /* Begin XCConfigurationList section */
230 | 84BFEE9E1C70827F009C9544 /* Build configuration list for PBXProject "api" */ = {
231 | isa = XCConfigurationList;
232 | buildConfigurations = (
233 | 84BFEEA81C70827F009C9544 /* Debug */,
234 | 84BFEEA91C70827F009C9544 /* Release */,
235 | );
236 | defaultConfigurationIsVisible = 0;
237 | defaultConfigurationName = Release;
238 | };
239 | 84BFEEAA1C70827F009C9544 /* Build configuration list for PBXNativeTarget "api" */ = {
240 | isa = XCConfigurationList;
241 | buildConfigurations = (
242 | 84BFEEAB1C70827F009C9544 /* Debug */,
243 | 84BFEEAC1C70827F009C9544 /* Release */,
244 | );
245 | defaultConfigurationIsVisible = 0;
246 | };
247 | /* End XCConfigurationList section */
248 | };
249 | rootObject = 84BFEE9B1C70827F009C9544 /* Project object */;
250 | }
251 |
--------------------------------------------------------------------------------
/rest/objectivec/api/ExmoApiHandler.h:
--------------------------------------------------------------------------------
1 | //
2 | // BtceApiHandler.h
3 | //
4 | //
5 |
6 | #import
7 |
8 | @interface ExmoApiHandler : NSObject
9 |
10 | @property (nonatomic,strong) NSString *api_key;
11 | @property (nonatomic,strong) NSString *secret_key;
12 |
13 | - (NSData *)getResponseFromServerForPost:(NSDictionary *)postDictionary method:(NSString *)methodName;
14 |
15 | - (NSData *)getResponseFromPublicServerUrl:(NSString *)urlString;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/rest/objectivec/api/ExmoApiHandler.m:
--------------------------------------------------------------------------------
1 | //
2 | // ExmoApiHandler.m
3 | //
4 | //
5 |
6 | #import "ExmoApiHandler.h"
7 | #import
8 |
9 | @implementation ExmoApiHandler
10 |
11 | @synthesize api_key;
12 | @synthesize secret_key;
13 |
14 | - (id)init {
15 | self = [super init];
16 | if (self) {
17 | [self setupInitialValues];
18 | }
19 | return self;
20 | }
21 |
22 | - (void)setupInitialValues {
23 | api_key = @"your_key";
24 | secret_key = @"your_secret";
25 | }
26 |
27 | //
28 |
29 | - (NSData *)getResponseFromServerForPost:(NSDictionary *)postDictionary method:(NSString *)methodName{
30 | NSString *post;
31 | int i = 0;
32 | for (NSString *key in [postDictionary allKeys]) {
33 | NSString *value = [postDictionary objectForKey:key];
34 | if (i==0)
35 | post = [NSString stringWithFormat:@"%@=%@", key, value];
36 | else
37 | post = [NSString stringWithFormat:@"%@&%@=%@", post, key, value];
38 | i++;
39 | }
40 | post = [NSString stringWithFormat:@"%@&nonce=%@", post, getNonce()];
41 |
42 |
43 | NSString *signedPost = hmacForKeyAndData(secret_key, post);
44 | NSString *url = [@"https://api.exmo.com/v1/" stringByAppendingString:methodName];
45 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
46 | initWithURL:
47 | [NSURL URLWithString: url]];
48 | [request setHTTPMethod:@"POST"];
49 | [request setValue:api_key forHTTPHeaderField:@"Key"];
50 | [request setValue:signedPost forHTTPHeaderField:@"Sign"];
51 | [request setHTTPBody:[post dataUsingEncoding: NSUTF8StringEncoding]];
52 |
53 | NSURLResponse *theResponse = NULL;
54 | NSError *theError = NULL;
55 | NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&theError];
56 | return responseData;
57 | }
58 |
59 | - (NSData *)getResponseFromPublicServerUrl:(NSString *)urlString {
60 | NSURL *url = [NSURL URLWithString:urlString];
61 | NSData *data = [NSData dataWithContentsOfURL:url];
62 | return data;
63 | }
64 |
65 | NSString *getNonce() {
66 | NSTimeInterval timeStamp = [[NSDate date] timeIntervalSinceDate:[NSDate dateWithString:@"2012-04-18 00:00:01 +0600"]];
67 | int currentNonce = [NSNumber numberWithDouble: timeStamp].intValue;
68 | NSString *nonceString = [NSString stringWithFormat:@"%i",currentNonce];
69 | return nonceString;
70 | }
71 |
72 | NSString *hmacForKeyAndData(NSString *key, NSString *data) {
73 | const char *cKey = [key cStringUsingEncoding:NSASCIIStringEncoding];
74 | const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];
75 | unsigned char cHMAC[CC_SHA512_DIGEST_LENGTH];
76 | CCHmac(kCCHmacAlgSHA512, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
77 | NSMutableString *hashString = [NSMutableString stringWithCapacity:sizeof(cHMAC) * 2];
78 | for (int i = 0; i < sizeof(cHMAC); i++) {
79 | [hashString appendFormat:@"%02x", cHMAC[i]];
80 | }
81 | return hashString;
82 | }
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/rest/objectivec/api/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // api
4 | //
5 | // Created by Admin on 14.02.16.
6 | // Copyright © 2016 exmo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ExmoApiHandler.h"
11 |
12 | ExmoApiHandler *apiHandler;
13 |
14 | int main(int argc, const char * argv[]) {
15 | @autoreleasepool {
16 | apiHandler = [[ExmoApiHandler alloc] init];
17 |
18 | NSMutableDictionary *post = [[NSMutableDictionary alloc] init];
19 |
20 | NSLog(@"user_info:\n");
21 | NSData *response = [apiHandler getResponseFromServerForPost:post method:@"user_info"];
22 | NSLog(@"%@\n",[[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]);
23 |
24 | NSLog(@"user_cancelled_orders:\n");
25 | NSMutableDictionary *post2 = [[NSMutableDictionary alloc] init];
26 |
27 | [post2 setObject:@"limit" forKey:@"100"];
28 | [post2 setObject:@"offset" forKey:@"0"];
29 |
30 | NSData *response2 = [apiHandler getResponseFromServerForPost:post2 method:@"user_cancelled_orders"];
31 | NSLog(@"%@\n",[[NSString alloc] initWithData:response2 encoding:NSUTF8StringEncoding]);
32 | int key;
33 | // insert code here...
34 |
35 | while (1)
36 | {
37 | NSLog(@"Press any key (q to quit):");
38 | fpurge(stdin);
39 | key = getc(stdin);
40 | if (key == 'q')
41 | {
42 | break;
43 | }
44 |
45 | NSLog(@"\nYou pressed: %c", (char)key);
46 | }
47 |
48 | }
49 | return 0;
50 | }
51 |
--------------------------------------------------------------------------------
/rest/php/exmo.php:
--------------------------------------------------------------------------------
1 | function api_query($api_name, array $req = array())
2 | {
3 | $mt = explode(' ', microtime());
4 | $NONCE = $mt[1] . substr($mt[0], 2, 6);
5 |
6 | // API settings
7 | $key = ""; //TODO replace with your api key from profile page
8 | $secret = ""; //TODO replace with your api secret from profile page
9 |
10 | $url = "https://api.exmo.com/v1/$api_name";
11 |
12 | $req['nonce'] = $NONCE;
13 |
14 | // generate the POST data string
15 | $post_data = http_build_query($req, '', '&');
16 |
17 | $sign = hash_hmac('sha512', $post_data, $secret);
18 |
19 | // generate the extra headers
20 | $headers = array(
21 | 'Sign: ' . $sign,
22 | 'Key: ' . $key,
23 | );
24 |
25 | // our curl handle (initialize if required)
26 | static $ch = null;
27 | if (is_null($ch)) {
28 | $ch = curl_init();
29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
31 | }
32 | curl_setopt($ch, CURLOPT_URL, $url);
33 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
34 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
35 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
36 |
37 | // run the query
38 | $res = curl_exec($ch);
39 | if ($res === false) throw new Exception('Could not get reply: ' . curl_error($ch));
40 |
41 | $dec = json_decode($res, true);
42 | if ($dec === null)
43 | throw new Exception('Invalid data received, please make sure connection is working and requested API exists');
44 |
45 | return $dec;
46 | }
47 |
--------------------------------------------------------------------------------
/rest/python/exmo2.py:
--------------------------------------------------------------------------------
1 | import httplib
2 | import urllib
3 | import json
4 | import hashlib
5 | import hmac
6 | import time
7 |
8 | api_key = "your_key"
9 | api_secret = "your_secret"
10 |
11 | nonce = int(round(time.time()*1000))
12 |
13 | params = {"nonce": nonce}
14 | params = urllib.urlencode(params)
15 |
16 | H = hmac.new(api_secret, digestmod=hashlib.sha512)
17 | H.update(params)
18 | sign = H.hexdigest()
19 |
20 | headers = {"Content-type": "application/x-www-form-urlencoded",
21 | "Key":api_key,
22 | "Sign":sign}
23 | conn = httplib.HTTPSConnection("api.exmo.com")
24 | conn.request("POST", "/v1/user_info", params, headers)
25 | response = conn.getresponse()
26 |
27 | print response.status, response.reason
28 | print json.load(response)
29 |
30 | conn.close()
--------------------------------------------------------------------------------
/rest/python/exmo3.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import http.client
3 | import urllib
4 | import json
5 | import hashlib
6 | import hmac
7 | import time
8 |
9 | class ExmoAPI:
10 | def __init__(self, API_KEY, API_SECRET, API_URL = 'api.exmo.com', API_VERSION = 'v1'):
11 | self.API_URL = API_URL
12 | self.API_VERSION = API_VERSION
13 | self.API_KEY = API_KEY
14 | self.API_SECRET = bytes(API_SECRET, encoding='utf-8')
15 |
16 | def sha512(self, data):
17 | H = hmac.new(key = self.API_SECRET, digestmod = hashlib.sha512)
18 | H.update(data.encode('utf-8'))
19 | return H.hexdigest()
20 |
21 | def api_query(self, api_method, params = {}):
22 | params['nonce'] = int(round(time.time() * 1000))
23 | params = urllib.parse.urlencode(params)
24 |
25 | sign = self.sha512(params)
26 | headers = {
27 | "Content-type": "application/x-www-form-urlencoded",
28 | "Key": self.API_KEY,
29 | "Sign": sign
30 | }
31 | conn = http.client.HTTPSConnection(self.API_URL)
32 | conn.request("POST", "/" + self.API_VERSION + "/" + api_method, params, headers)
33 | response = conn.getresponse().read()
34 |
35 | conn.close()
36 |
37 | try:
38 | obj = json.loads(response.decode('utf-8'))
39 | if 'error' in obj and obj['error']:
40 | print(obj['error'])
41 | raise sys.exit()
42 | return obj
43 | except json.decoder.JSONDecodeError:
44 | print('Error while parsing response:', response)
45 | raise sys.exit()
46 |
47 | # Example
48 | ExmoAPI_instance = ExmoAPI('YOUR API KEY', 'YOUR API SECRET')
49 | print(ExmoAPI_instance.api_query('user_info'))
50 |
51 | # print(ExmoAPI_instance.api_query('order_create', {
52 | # "pair": 'DOGE_BTC',
53 | # "quantity":100,
54 | # "price":0.00001,
55 | # "type":"sell"
56 | # })
57 | # )
58 |
59 | # print(ExmoAPI_instance.api_query('order_cancel', {
60 | # "order_id": 3063120293
61 | # })
62 | # )
63 |
--------------------------------------------------------------------------------
/rest/r/exmo.r:
--------------------------------------------------------------------------------
1 | library(httr)
2 | library(jsonlite)
3 | library(nanotime)
4 | library(digest)
5 |
6 | api_url <- "https://api.exmo.com/v1/"
7 | api_key <- "K-..."
8 | api_secret <- "S-..."
9 |
10 | api_query <- function(method, key, secret, params = list()){
11 |
12 | nonce <- (as.numeric(as.POSIXct(Sys.time()))*10000000)%/%1
13 |
14 | params <- c(params, nonce = nonce)
15 |
16 | data <- paste(names(params), params, sep = "=", collapse = "&")
17 |
18 | signature <-
19 | hmac(
20 | key = secret,
21 | object = data,
22 | algo = "sha512"
23 | )
24 |
25 | response <- POST(
26 | url = paste(api_url, method, sep = ""),
27 | accept_json(),
28 | add_headers(
29 | "Key" = key,
30 | "Sign" = signature,
31 | "Content-Type" = "application/x-www-form-urlencoded"
32 | ),
33 | body = data
34 | )
35 |
36 | exmo_content <- content(response, as="text")
37 | json_exmo_content <- fromJSON(exmo_content)
38 | return(json_exmo_content)
39 | }
40 |
41 | params <- list(
42 | pair = "ETH_BTC",
43 | limit = 100,
44 | offset = 0
45 |
46 | )
47 |
48 | api_query("user_trades", api_key, api_secret, params)
49 | api_query("user_info", api_key, api_secret)
--------------------------------------------------------------------------------
/rest/ruby/exmo.rb:
--------------------------------------------------------------------------------
1 | require 'net/https'
2 | require "json"
3 |
4 | module Exmo
5 | class Error < StandardError
6 | attr_reader :object
7 |
8 | def initialize(object)
9 | @object = object
10 | end
11 | end
12 |
13 | class API
14 | class << self
15 | KEY = "K-b123456" # TODO replace with your api key from settings page
16 | SECRET = "S-e123456" # TODO replace with your api secret from settings page
17 |
18 | def api_query(method, params = nil)
19 | raise ArgumentError unless method.is_a?(String) || method.is_a?(Symbol)
20 |
21 | params = {} if params.nil?
22 | params['nonce'] = nonce
23 |
24 | uri = URI.parse(['https://api.exmo.com/v1', method].join('/'))
25 |
26 | post_data = URI.encode_www_form(params)
27 |
28 | digest = OpenSSL::Digest.new('sha512')
29 | sign = OpenSSL::HMAC.hexdigest(digest, SECRET, post_data)
30 |
31 | headers = {
32 | 'Sign' => sign,
33 | 'Key' => KEY
34 | }
35 |
36 | req = Net::HTTP::Post.new(uri.path, headers)
37 | req.body = post_data
38 | http = Net::HTTP.new(uri.host, uri.port)
39 | http.use_ssl = true if uri.scheme == 'https'
40 | response = http.request(req)
41 |
42 | unless response.code == '200'
43 | raise Exmo::Error.new(__method__), ['http error:', response.code].join(' ')
44 | end
45 |
46 | result = response.body.to_s
47 |
48 | unless result.is_a?(String) && valid_json?(result)
49 | raise Exmo::Error.new(__method__), "Invalid json"
50 | end
51 |
52 | JSON.load result
53 | end
54 |
55 | private
56 |
57 | def valid_json?(json)
58 | JSON.parse(json)
59 | true
60 | rescue
61 | false
62 | end
63 |
64 | def nonce
65 | Time.now.strftime("%s%6N")
66 | end
67 | end
68 | end
69 | end
70 |
71 |
72 |
73 | puts "%s" % Exmo::API.api_query('user_info').inspect
74 |
75 |
76 |
77 | # puts "%s" % Exmo::API.api_query('trades', pair: 'DOGE_USD').inspect
78 | # puts "%s" % Exmo::API.api_query('order_trades', order_id: 12345).inspect
79 | # puts "%s" % Exmo::API.api_query('order_book', pair: 'DOGE_USD', limit: 10).inspect
80 | # puts "%s" % Exmo::API.api_query('ticker').inspect
81 | # puts "%s" % Exmo::API.api_query('pair_settings').inspect
82 | # puts "%s" % Exmo::API.api_query('currency').inspect
83 |
84 | # order_params = {
85 | # pair: 'DOGE_USD',
86 | # quantity: 100,
87 | # price: 99,
88 | # type: 'sell'
89 | # }
90 | # puts "%s" % Exmo::API.api_query('order_create', order_params).inspect
91 |
92 | # puts "%s" % Exmo::API.api_query('user_open_orders').inspect
93 | # puts "%s" % Exmo::API.api_query('order_cancel', order_id: 12345).inspect
94 | # puts "%s" % Exmo::API.api_query('user_cancelled_orders', limit: 100, offset: 0).inspect
95 |
96 | # puts "%s" % Exmo::API.api_query('order_trades', order_id: 12345).inspect
97 | # puts "%s" % Exmo::API.api_query('required_amount', pair: 'BTC_USD', quantity: 10).inspect
98 | # puts "%s" % Exmo::API.api_query('deposit_address').inspect
99 |
--------------------------------------------------------------------------------
/rest/swift/api-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // api-Bridging-Header.h
3 | // api
4 | //
5 | // Created by Admin on 14.02.16.
6 | // Copyright © 2016 exmo. All rights reserved.
7 | //
8 |
9 | #ifndef api_Bridging_Header_h
10 | #define api_Bridging_Header_h
11 |
12 | #import
13 |
14 | #endif /* api_Bridging_Header_h */
15 |
--------------------------------------------------------------------------------
/rest/swift/api.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 84BFEEBD1C70911E009C9544 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BFEEBC1C70911E009C9544 /* main.swift */; };
11 | 84BFEEC41C709199009C9544 /* ApiHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BFEEC31C709199009C9544 /* ApiHandler.swift */; };
12 | 84BFEEC61C7095A6009C9544 /* NSData+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BFEEC51C7095A6009C9544 /* NSData+Extensions.swift */; };
13 | /* End PBXBuildFile section */
14 |
15 | /* Begin PBXCopyFilesBuildPhase section */
16 | 84BFEEB71C70911E009C9544 /* CopyFiles */ = {
17 | isa = PBXCopyFilesBuildPhase;
18 | buildActionMask = 2147483647;
19 | dstPath = /usr/share/man/man1/;
20 | dstSubfolderSpec = 0;
21 | files = (
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 84BFEEB91C70911E009C9544 /* api */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = api; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 84BFEEBC1C70911E009C9544 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; };
30 | 84BFEEC31C709199009C9544 /* ApiHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiHandler.swift; sourceTree = ""; };
31 | 84BFEEC51C7095A6009C9544 /* NSData+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSData+Extensions.swift"; sourceTree = ""; };
32 | 84BFEEC71C709A1A009C9544 /* api-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "api-Bridging-Header.h"; sourceTree = ""; };
33 | /* End PBXFileReference section */
34 |
35 | /* Begin PBXFrameworksBuildPhase section */
36 | 84BFEEB61C70911E009C9544 /* Frameworks */ = {
37 | isa = PBXFrameworksBuildPhase;
38 | buildActionMask = 2147483647;
39 | files = (
40 | );
41 | runOnlyForDeploymentPostprocessing = 0;
42 | };
43 | /* End PBXFrameworksBuildPhase section */
44 |
45 | /* Begin PBXGroup section */
46 | 84BFEEB01C70911E009C9544 = {
47 | isa = PBXGroup;
48 | children = (
49 | 84BFEEC71C709A1A009C9544 /* api-Bridging-Header.h */,
50 | 84BFEEBB1C70911E009C9544 /* api */,
51 | 84BFEEBA1C70911E009C9544 /* Products */,
52 | );
53 | sourceTree = "";
54 | };
55 | 84BFEEBA1C70911E009C9544 /* Products */ = {
56 | isa = PBXGroup;
57 | children = (
58 | 84BFEEB91C70911E009C9544 /* api */,
59 | );
60 | name = Products;
61 | sourceTree = "";
62 | };
63 | 84BFEEBB1C70911E009C9544 /* api */ = {
64 | isa = PBXGroup;
65 | children = (
66 | 84BFEEBC1C70911E009C9544 /* main.swift */,
67 | 84BFEEC31C709199009C9544 /* ApiHandler.swift */,
68 | 84BFEEC51C7095A6009C9544 /* NSData+Extensions.swift */,
69 | );
70 | path = api;
71 | sourceTree = "";
72 | };
73 | /* End PBXGroup section */
74 |
75 | /* Begin PBXNativeTarget section */
76 | 84BFEEB81C70911E009C9544 /* api */ = {
77 | isa = PBXNativeTarget;
78 | buildConfigurationList = 84BFEEC01C70911E009C9544 /* Build configuration list for PBXNativeTarget "api" */;
79 | buildPhases = (
80 | 84BFEEB51C70911E009C9544 /* Sources */,
81 | 84BFEEB61C70911E009C9544 /* Frameworks */,
82 | 84BFEEB71C70911E009C9544 /* CopyFiles */,
83 | );
84 | buildRules = (
85 | );
86 | dependencies = (
87 | );
88 | name = api;
89 | productName = api;
90 | productReference = 84BFEEB91C70911E009C9544 /* api */;
91 | productType = "com.apple.product-type.tool";
92 | };
93 | /* End PBXNativeTarget section */
94 |
95 | /* Begin PBXProject section */
96 | 84BFEEB11C70911E009C9544 /* Project object */ = {
97 | isa = PBXProject;
98 | attributes = {
99 | LastSwiftUpdateCheck = 0720;
100 | LastUpgradeCheck = 0720;
101 | ORGANIZATIONNAME = exmo;
102 | TargetAttributes = {
103 | 84BFEEB81C70911E009C9544 = {
104 | CreatedOnToolsVersion = 7.2.1;
105 | };
106 | };
107 | };
108 | buildConfigurationList = 84BFEEB41C70911E009C9544 /* Build configuration list for PBXProject "api" */;
109 | compatibilityVersion = "Xcode 3.2";
110 | developmentRegion = English;
111 | hasScannedForEncodings = 0;
112 | knownRegions = (
113 | en,
114 | );
115 | mainGroup = 84BFEEB01C70911E009C9544;
116 | productRefGroup = 84BFEEBA1C70911E009C9544 /* Products */;
117 | projectDirPath = "";
118 | projectRoot = "";
119 | targets = (
120 | 84BFEEB81C70911E009C9544 /* api */,
121 | );
122 | };
123 | /* End PBXProject section */
124 |
125 | /* Begin PBXSourcesBuildPhase section */
126 | 84BFEEB51C70911E009C9544 /* Sources */ = {
127 | isa = PBXSourcesBuildPhase;
128 | buildActionMask = 2147483647;
129 | files = (
130 | 84BFEEBD1C70911E009C9544 /* main.swift in Sources */,
131 | 84BFEEC41C709199009C9544 /* ApiHandler.swift in Sources */,
132 | 84BFEEC61C7095A6009C9544 /* NSData+Extensions.swift in Sources */,
133 | );
134 | runOnlyForDeploymentPostprocessing = 0;
135 | };
136 | /* End PBXSourcesBuildPhase section */
137 |
138 | /* Begin XCBuildConfiguration section */
139 | 84BFEEBE1C70911E009C9544 /* Debug */ = {
140 | isa = XCBuildConfiguration;
141 | buildSettings = {
142 | ALWAYS_SEARCH_USER_PATHS = NO;
143 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
144 | CLANG_CXX_LIBRARY = "libc++";
145 | CLANG_ENABLE_MODULES = YES;
146 | CLANG_ENABLE_OBJC_ARC = YES;
147 | CLANG_WARN_BOOL_CONVERSION = YES;
148 | CLANG_WARN_CONSTANT_CONVERSION = YES;
149 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
150 | CLANG_WARN_EMPTY_BODY = YES;
151 | CLANG_WARN_ENUM_CONVERSION = YES;
152 | CLANG_WARN_INT_CONVERSION = YES;
153 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
154 | CLANG_WARN_UNREACHABLE_CODE = YES;
155 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
156 | CODE_SIGN_IDENTITY = "-";
157 | COPY_PHASE_STRIP = NO;
158 | DEBUG_INFORMATION_FORMAT = dwarf;
159 | ENABLE_STRICT_OBJC_MSGSEND = YES;
160 | ENABLE_TESTABILITY = YES;
161 | GCC_C_LANGUAGE_STANDARD = gnu99;
162 | GCC_DYNAMIC_NO_PIC = NO;
163 | GCC_NO_COMMON_BLOCKS = YES;
164 | GCC_OPTIMIZATION_LEVEL = 0;
165 | GCC_PREPROCESSOR_DEFINITIONS = (
166 | "DEBUG=1",
167 | "$(inherited)",
168 | );
169 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
170 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
171 | GCC_WARN_UNDECLARED_SELECTOR = YES;
172 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
173 | GCC_WARN_UNUSED_FUNCTION = YES;
174 | GCC_WARN_UNUSED_VARIABLE = YES;
175 | MACOSX_DEPLOYMENT_TARGET = 10.11;
176 | MTL_ENABLE_DEBUG_INFO = YES;
177 | ONLY_ACTIVE_ARCH = YES;
178 | SDKROOT = macosx;
179 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
180 | };
181 | name = Debug;
182 | };
183 | 84BFEEBF1C70911E009C9544 /* Release */ = {
184 | isa = XCBuildConfiguration;
185 | buildSettings = {
186 | ALWAYS_SEARCH_USER_PATHS = NO;
187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
188 | CLANG_CXX_LIBRARY = "libc++";
189 | CLANG_ENABLE_MODULES = YES;
190 | CLANG_ENABLE_OBJC_ARC = YES;
191 | CLANG_WARN_BOOL_CONVERSION = YES;
192 | CLANG_WARN_CONSTANT_CONVERSION = YES;
193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
194 | CLANG_WARN_EMPTY_BODY = YES;
195 | CLANG_WARN_ENUM_CONVERSION = YES;
196 | CLANG_WARN_INT_CONVERSION = YES;
197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
198 | CLANG_WARN_UNREACHABLE_CODE = YES;
199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
200 | CODE_SIGN_IDENTITY = "-";
201 | COPY_PHASE_STRIP = NO;
202 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
203 | ENABLE_NS_ASSERTIONS = NO;
204 | ENABLE_STRICT_OBJC_MSGSEND = YES;
205 | GCC_C_LANGUAGE_STANDARD = gnu99;
206 | GCC_NO_COMMON_BLOCKS = YES;
207 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
208 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
209 | GCC_WARN_UNDECLARED_SELECTOR = YES;
210 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
211 | GCC_WARN_UNUSED_FUNCTION = YES;
212 | GCC_WARN_UNUSED_VARIABLE = YES;
213 | MACOSX_DEPLOYMENT_TARGET = 10.11;
214 | MTL_ENABLE_DEBUG_INFO = NO;
215 | SDKROOT = macosx;
216 | };
217 | name = Release;
218 | };
219 | 84BFEEC11C70911E009C9544 /* Debug */ = {
220 | isa = XCBuildConfiguration;
221 | buildSettings = {
222 | PRODUCT_NAME = "$(TARGET_NAME)";
223 | SWIFT_OBJC_BRIDGING_HEADER = "api-Bridging-Header.h";
224 | };
225 | name = Debug;
226 | };
227 | 84BFEEC21C70911E009C9544 /* Release */ = {
228 | isa = XCBuildConfiguration;
229 | buildSettings = {
230 | PRODUCT_NAME = "$(TARGET_NAME)";
231 | SWIFT_OBJC_BRIDGING_HEADER = "api-Bridging-Header.h";
232 | };
233 | name = Release;
234 | };
235 | /* End XCBuildConfiguration section */
236 |
237 | /* Begin XCConfigurationList section */
238 | 84BFEEB41C70911E009C9544 /* Build configuration list for PBXProject "api" */ = {
239 | isa = XCConfigurationList;
240 | buildConfigurations = (
241 | 84BFEEBE1C70911E009C9544 /* Debug */,
242 | 84BFEEBF1C70911E009C9544 /* Release */,
243 | );
244 | defaultConfigurationIsVisible = 0;
245 | defaultConfigurationName = Release;
246 | };
247 | 84BFEEC01C70911E009C9544 /* Build configuration list for PBXNativeTarget "api" */ = {
248 | isa = XCConfigurationList;
249 | buildConfigurations = (
250 | 84BFEEC11C70911E009C9544 /* Debug */,
251 | 84BFEEC21C70911E009C9544 /* Release */,
252 | );
253 | defaultConfigurationIsVisible = 0;
254 | };
255 | /* End XCConfigurationList section */
256 | };
257 | rootObject = 84BFEEB11C70911E009C9544 /* Project object */;
258 | }
259 |
--------------------------------------------------------------------------------
/rest/swift/api/ApiHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ApiHandler.swift
3 | // api
4 | //
5 | // Created by Admin on 14.02.16.
6 | // Copyright © 2016 exmo. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import AppKit
11 |
12 | public class ApiHandler: NSObject {
13 | private enum Config: String{
14 | case API_URL = "https://api.exmo.com/v1/"
15 | case API_KEY = "your_key"
16 | case API_SECRET = "your_secret"
17 | case NONCE = "Nonce"
18 | }
19 |
20 |
21 |
22 | private var api_key: String!
23 | private var secret_key: String!
24 |
25 |
26 |
27 | private var nonce: Int{
28 | get{
29 | let value = NSUserDefaults.standardUserDefaults().integerForKey(Config.NONCE.rawValue)
30 | return (value == 0) ? calculateInitialNonce(): value
31 | }
32 | set{
33 | NSUserDefaults.standardUserDefaults().setObject(newValue, forKey: Config.NONCE.rawValue)
34 | }
35 | }
36 |
37 | override init() {
38 | super.init()
39 | setupInitValues()
40 | }
41 |
42 | internal func setupInitValues(){
43 | self.api_key = Config.API_KEY.rawValue
44 | self.secret_key = Config.API_SECRET.rawValue
45 | }
46 |
47 | public func userInfo()-> NSData?{
48 | NSLog("start user_info")
49 | let post = NSMutableDictionary()
50 | return self.getResponseFromServerForPost(post, method:"user_info")
51 | }
52 |
53 | public func canceledOrders(limit:Int, offset:Int)-> NSData?{
54 | NSLog("start user_cancelled_orders")
55 | let post = NSMutableDictionary()
56 | post.setObject(limit, forKey: "limit")
57 | post.setObject(offset, forKey: "offset")
58 | return self.getResponseFromServerForPost(post, method:"user_cancelled_orders")
59 | }
60 |
61 | private func getResponseFromServerForPost(postDictionary: NSDictionary, method: String) -> NSData?{
62 | var post: String!
63 | var i: Int = 0
64 | for (key, value) in postDictionary {
65 | if (i==0){
66 | post = "\(key)=\(value)"
67 | }else{
68 | post = "\(post)&\(key)=\(value)"
69 | }
70 | i++;
71 | }
72 | post = "\(post)&nonce=\(nonce)"
73 | nonce++
74 | print(post)
75 | let signedPost = hmacForKeyAndData(secret_key, data: post) as String
76 | let request = NSMutableURLRequest(URL: NSURL(string: Config.API_URL.rawValue as String + method)!)
77 | request.HTTPMethod = "POST"
78 | request.setValue(api_key, forHTTPHeaderField: "Key")
79 | request.setValue(signedPost, forHTTPHeaderField: "Sign")
80 |
81 | let requestBodyData = (post as NSString).dataUsingEncoding(NSUTF8StringEncoding)
82 | request.HTTPBody = requestBodyData
83 |
84 | var error: NSError?
85 | let theResponse: AutoreleasingUnsafeMutablePointer =nil
86 | let responseData = try! NSURLConnection.sendSynchronousRequest(request, returningResponse: theResponse) as NSData!
87 | if (error != nil){
88 | return nil
89 | }
90 |
91 | return responseData
92 | }
93 |
94 | private func calculateInitialNonce()->Int{
95 | let dataFormat = NSDateFormatter()
96 | dataFormat.dateFormat = "yyyy-MM-dd HH:mm:ss xxxx"
97 | let timeStamp = NSDate().timeIntervalSinceDate(dataFormat.dateFromString("2012-04-18 00:00:03 +0600")!)
98 | let currentNonce = NSNumber(double: timeStamp) as Int
99 | return currentNonce
100 | }
101 |
102 |
103 | private func hmacForKeyAndData(key: NSString, data: NSString)->NSString{
104 | let cKey = key.cStringUsingEncoding(NSASCIIStringEncoding)
105 | let cData = data.cStringUsingEncoding(NSASCIIStringEncoding)
106 | let _ = [CUnsignedChar](count: Int(CC_SHA512_DIGEST_LENGTH), repeatedValue: 0)
107 | let digestLen = Int(CC_SHA512_DIGEST_LENGTH)
108 | let result = UnsafeMutablePointer.alloc(digestLen)
109 | print("CCHmac")
110 | CCHmac(CCHmacAlgorithm(kCCHmacAlgSHA512), cKey, Int(key.length), cData, Int(data.length), result)
111 | let hashString = NSMutableString(capacity: Int(CC_SHA512_DIGEST_LENGTH))
112 | for i in 0.. NSDictionary?{
12 | if let json = try! NSJSONSerialization.JSONObjectWithData(self, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary{
13 | return json
14 | }else{
15 | return nil
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/rest/swift/api/main.swift:
--------------------------------------------------------------------------------
1 | //
2 | // main.swift
3 | // api
4 | //
5 | // Created by Admin on 14.02.16.
6 | // Copyright © 2016 exmo. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | let api = ApiHandler()
12 | let result = api.userInfo()
13 | let dataString = String(data: result!, encoding: NSUTF8StringEncoding)
14 | NSLog(dataString!)
15 |
16 | let result2 = api.canceledOrders(100, offset: 0)
17 | let dataString2 = String(data: result2!, encoding: NSUTF8StringEncoding)
18 | NSLog(dataString2!)
--------------------------------------------------------------------------------
/rest/с++/README.md:
--------------------------------------------------------------------------------
1 | Dependencies: CURL, OpenSSL
2 |
3 |
--------------------------------------------------------------------------------
/rest/с++/connection.hpp:
--------------------------------------------------------------------------------
1 | #ifndef HTTP_CONNECTION_HPP
2 | #define HTTP_CONNECTION_HPP
3 |
4 | #include "curl_object.hpp"
5 | #include
6 | #include
7 | #include