Official SDK

๐Ÿ“š GitHub Demo

You can find the official SDK and usage examples here: ๐ŸŒ Coinlocally SDK on GitHubarrow-up-right


๐Ÿ” Signature Generation Example (Java)

javaCopyEdit/**
 * Generate request signature
 */
private String toSign(String timestamp, String method, String requestPath,
                      String queryString, String body, String secretKey) throws Exception {
    String preHash = preHash(timestamp, method, requestPath, queryString, body);
    SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256");
    Mac mac = Mac.getInstance("HmacSHA256");
    mac.init(secretKeySpec);
    return Hex.encodeHexString(mac.doFinal(preHash.getBytes("UTF-8")));
}

/**
 * Construct the string to be signed
 */
private String preHash(String timestamp, String method, String requestPath,
                       String queryString, String body) {
    StringBuilder preHash = new StringBuilder()
        .append(timestamp)
        .append(method.toUpperCase())
        .append(requestPath);

    if (StringUtils.isNotEmpty(queryString)) {
        preHash.append("?").append(queryString);
    }
    if (StringUtils.isNotEmpty(body)) {
        preHash.append(body);
    }
    return preHash.toString();
}

/**
 * Extract query string from request URL
 */
private String queryString(ServerHttpRequest request) {
    String url = request.getURI().toString();
    return url.contains("?") ? url.substring(url.lastIndexOf("?") + 1) : "";
}

๐Ÿ“ฆ Create Order Examples (By Language)

โœ… Java (Using OkHttp)

๐Ÿ Python

๐ŸŒ Go

๐Ÿ“˜ PHP

โš™๏ธ Node.js

Last updated