Obtain exchange rate basic information port

1.Call frequency limit

Provide the exchange rate between two tokens, the exchange rate update rate is 5-10s​

2.Port Change

For detail parameters reference the API port document, obtaining basic information port api/v1/getBaseInfo ,request method is POSTapplication/json

3.Code Example

java code example

OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"depositCoinCode\":\"BTC\",\"receiveCoinCode\":\"ETH\"}");
Request request = new Request.Builder()
.url("https://transfer.swft.pro/api/v1/getBaseInfo")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();

C# code example

var client = new RestClient("https://transfer.swft.pro/api/v1/getBaseInfo");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\"depositCoinCode\":\"BTC\",\"receiveCoinCode\":\"ETH\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Objective-C code example

#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"Content-Type": @"application/json",
@"cache-control": @"no-cache" };
NSDictionary *parameters = @{ @"depositCoinCode": @"BTC",
@"receiveCoinCode": @"ETH" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://transfer.swft.pro/api/v1/getBaseInfo"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];

Nodejs code example

var http = require("https");
var options = {
"method": "POST",
"hostname": [
"transfer",
"swft",
"pro"
],
"path": [
"api",
"v1",
"getBaseInfo"
],
"headers": {
"Content-Type": "application/json",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ depositCoinCode: 'BTC', receiveCoinCode: 'ETH' }));
req.end();

4.Response result example

{
"data": {
"depositMax": "1692690",
"depositMin": "169269",
"instantRate": "0.000000538438",
"minerFee": "0.00004368",
"receiveCoinFee": "0.009328"
},
"resCode": "800",
"resMsg": "成功"
}

Parameter

Explanation

minerFee

This value is for deposited tokens that utilize SWFTC for the exchange fee, SWFTC exchange fee = deposited amount * minerFee

receiveCoinFee

This value is the amount of network fee deducted after successful transfer, the units are displayed in the token type the user is receiving/buying, this can be used to calculate the approximate amount of tokens that the user will receive, or it will be used to display the amount of network fees deducted to complete the transfer.

Important Items:

For advanced trading, user's fee method is the deposited tokens, not SWFTC, therefore this parameter can be ignored, the transaction fee is fixed at 0.1% (ex.: if depositing 0.1 BTC, the actual amount deducted is 0.0001btc as the transfer's transaction fee, when actually exchange, only 0.0999btc will be transferred)

For a detailed explanation of returned values, please see the Google document

Business Reference Graph