> For the complete documentation index, see [llms.txt](https://whitepaper.nomoex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.nomoex.com/api-documentation/official-sdk.md).

# Official SDK

#### Signed example <a href="#signed-example" id="signed-example"></a>

<pre><code>/**
 * queryString
 **/
<strong>private String toSign(String timestamp, String method, String requestPath,
</strong>                             String queryString, String body, String secretKey) throws Exception {
    // 
    String preHash = preHash(timestamp, method, requestPath, queryString, body);
    byte[] secretKeyBytes = secretKey.getBytes("UTF-8");
    SecretKeySpec secretKeySpec = new SecretKeySpec(secretKeyBytes, "HmacSHA256");
    Mac mac = (Mac) MAC.clone();
    mac.init(secretKeySpec);
    return Hex.encodeHexString(mac.doFinal(preHash.getBytes("UTF-8")));
}

/**
 * queryString
 **/
private String preHash(String timestamp, String method, String requestPath, String queryString, String body) {
                                 
    StringBuilder preHash = new StringBuilder();
    preHash.append(timestamp);
    preHash.append(method.toUpperCase());
    preHash.append(requestPath);
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(queryString)) {
        preHash.append("?").append(queryString);
    }
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(body)) {
        preHash.append(body);
    }
    return preHash.toString();
}

/**
 * queryString
 **/
private String queryString(ServerHttpRequest request) {
    String url = request.getURI().toString();
    String queryString = "";
    if (url.contains("?")) {
        queryString = url.substring(url.lastIndexOf("?") + 1);
    }
    return queryString;
}
</code></pre>

#### Here is a example of how to create order <a href="#here-is-a-example-of-how-to-create-order" id="here-is-a-example-of-how-to-create-order"></a>

* Java

```
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"symbol\":\"BTCUSDT\",\"volume\":1,\"side\":\"BUY\",\"type\":\"LIMIT\",\"price\":10000,\"newClientOrderId\":\"\",\"recvWindow\":5000}");
Request request = new Request.Builder()
  .url("https://openapi.xxx.com")
  .method("POST", body)
  .addHeader("X-CH-APIKEY", "Your API key")
  .addHeader("X-CH-TS", "1596543296058")
  .addHeader("Content-Type", "application/json")
  .addHeader("X-CH-SIGN", "encrypt sign")
  .build();
Response response = client.newCall(request).execute();
```

* Go

```
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://openapi.nomoex.com"
  method := "POST"

  payload := strings.NewReader("{\"symbol\":\"BTCUSDT\",\"volume\":1,\"side\":\"BUY\",\"type\":\"LIMIT\",\"price\":10000,\"newClientOrderId\":\"\",\"recvWindow\":5000}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("X-CH-APIKEY", "Your API key")
  req.Header.Add("X-CH-TS", "1596543881257")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("X-CH-SIGN", "encrypt sign")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
```

* Python

```
import requests

url = "https://openapi.nomoex.com"

payload = "{\"symbol\":\"BTCUSDT\",\"volume\":1,\"side\":\"BUY\",\"type\":\"LIMIT\",\"price\":10000,\"newClientOrderId\":\"\",\"recvWindow\":5000}"
headers = {
  'X-CH-APIKEY': 'Your API key',
  'X-CH-TS': '1596543881257',
  'Content-Type': 'application/json',
  'X-CH-SIGN': 'encrypt sign'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
```

* Php

```
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://openapi.xxx.com');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'X-CH-APIKEY' => 'Your API key',
  'X-CH-TS' => '1596543881257',
  'Content-Type' => 'application/json',
  'X-CH-SIGN' => 'encrypt sign'
));
$request->setBody('{"symbol":"BTCUSDT","volume":1,"side":"BUY","type":"LIMIT","price":10000,"newClientOrderId":"","recvWindow":5000}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

* NodeJS

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://openapi.nomoex.com',
  'headers': {
    'X-CH-APIKEY': 'Your API key',
    'X-CH-TS': '1596543881257',
    'Content-Type': 'application/json',
    'X-CH-SIGN': 'encrypt sign'
  },
  body: JSON.stringify({"symbol":"BTCUSDT","volume":1,"side":"BUY","type":"LIMIT","price":10000,"newClientOrderId":"","recvWindow":5000})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://whitepaper.nomoex.com/api-documentation/official-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
