API

SharpTrade API is an easy and effective tool for you to integrate our cryptocurrency exchange service to carry out transactions anywhere anytime.

API Technical Documentation

Usage Diagram Usage

Socket Server

SharpTrade Socket Server will publish transaction status updates to corresponding connected clients. The subscription should be signed and have a valid current timestamp in message.

Javascript example

const io = require('socket.io-client');
const crypto = require('crypto');

let serverUrl, apiKey, apiSecret;

let socket = io(serverUrl);

socket.on('info', (msg) => {
    console.info('[INFO]', msg);
});

socket.on('subscribe_error', (err) => {
    console.error('[SUBSCRIBE_ERROR]', err);
});

socket.on('status', (data) => {
    console.info('[STATUS]', data);
});

socket.on('disconnect', () => {
    console.log('[SOCKET]', 'disconnected');
});

socket.on('connect', () => {
    console.log('[SOCKET]', 'connected');
    let ts = Math.floor(Date.now() / 1000);
    let message = {ts: ts};
    let sign = crypto
        .createHmac('sha512', apiSecret)
        .update(JSON.stringify(message))
        .digest('hex');

    socket.emit('subscribe', {
        apiKey: apiKey,
        sign: sign,
        message: message
    });
});

`status` event sample data

{
    "id": "n56kh",
    "status": "finished",
    "currencyFrom": "ltc",
    "currencyTo": "eth",
    "amountFrom": "10",
    "amountTo": "0.2",
    "networkFee": "0.01",
    "payinHash": "9f19186213799b82776c5792238c6b1c016504bb7003346f890bf754b36f69ca",
    "payinAddress": "NBLQ6PE7Z5CVANJNXGOR74UQLOJ2YMGJJOZ4YFAQ",
    "payinExtraId": null,
    "payoutHash": "0x1d04f3df2f7209ca985895ecf2e31a07e04889367d37d98c1e8d90fdfb568ec8",
    "payoutAddress": "0x988fa9Bb5C0a462932d9C714E2643a4692E4ABc5",
    "payoutExtraId": null
}

Authentication

All requests must contain Api-Key and Sign in the header. The signature is calculated according to the HMAC-SHA512 method with the query's serialized body and API Secret.

Javascript example

const crypto = require('crypto');

let data = {
    from: 'btc',
    to: 'eth',
    amt: 1
};

let sign = crypto
    .createHmac('sha512', apiSecret)
    .update(JSON.stringify(data))
    .digest('hex');

Appendix

Transaction Status Code Code
finished  =  0
init  =  100
error  =  101
new  =  200
waiting  =  300
expired  =  311
confirming  =  400
error  =  401
failed  =  411
exchanging  =  500
sending  =  600
refunded  =  700
API Response Status Code Code
success  =  0
server error  =  -1
invalid argument  =  -2
merchant not found  =  -1000
currency not found  =  -2000
pair not found  =  -2001
invalid wallet  =  -2002
transaction not found  =  -3000