Integration Guide

TIP

To learn more about the Peer V1 API, please read the Introduction.

Authentication

NOTE

Please visit Peer's website to generate an API key.

Mainnet

API Key Type

System-generated API Keys: The API key generated by the Peer system operates with HMAC encryption. You will be provided with a pair of public and private keys. Please treat this pair of keys as passwords and keep them safe.

Paramenters for Authenticated Endpoints

The following HTTP header keys must be used for authentication:

  • X-PEER-API-KEY - API key
  • X-PEER-SIGN - a signature derived from the request's parameters

Create A Request

  1. Basic steps: API key + (queryString | jsonBodyString)
  2. Use the HMAC_SHA256 algorithm to sign the string in step 1, and convert it to a hex string (HMAC_SHA256) to obtain the sign parameter.
  3. Append the sign parameter to request header, and send the HTTP request.
// Generate HMAC signature
import crypto from 'crypto'; 
 
const apiKey = 'XXXXXXXXXXXXXX';
const secretKey = 'XXXXXXXXXXXXXX'
 
const requestBody = JSON.stringify({
  coin: "BTCUSDT",
  side: "short",
  entryPrice: 83572,
  leverage: 1,
  size: 1,
  marginMode: "Isolated",
  type: "limit"
});
 
const signature = crypto
  .createHmac('sha256', secretKey)
  .update(apiKey + requestBody)
  .digest('hex');

An example for how to generate plain text to encrypt

# rule:
api_key+queryString
 
# param_str
"XXXXXXXXXXcategory=option&symbol=BTC-29JUL22-25000-C"
 
# parse
api_key = "XXXXXXXXXX"
queryString = "category=option&symbol=BTC-29JUL22-25000-C"

HTTP request examples

GET /v1/order/realtime?category=option&symbol=BTC-29JUL22-2-C HTTP/1.1
Host: api.peer-kr.com
-H 'X-PEER-SIGN: XXXXXXXXXX' \
-H 'X-PEER-API-KEY: XXXXXXXXXX' \

Common response parameters

ParamenterTypeComments
statusCodenumberSuccess/Error Code
resultstringSuccess/Error String
messagestringSuccess/Error Message
{
  "statusCode": 200,
  "result": "Success",
  "message": "Order Placed successfully!",
}

On this page