API Authentication
API Authentication
Use Ed25519 request signatures to access private PangoPerps API endpoints. Public market data does not require these authentication headers.
Create a signed request
Each authenticated request includes the account ID, the public half of a registered API key, a current timestamp, and a signature made with that key’s private half.
1. Add the account ID
After the account has been registered, include its account ID in the orderly-account-id request header.
2. Add the API public key
Put the registered Ed25519 public key in the orderly-key header. Encode the key in Base58 and include the ed25519: key-type prefix, for example:
ed25519:<base58-public-key>The secret key is used locally to sign the request. Never send the secret key to the API.
3. Set the request timestamp
Read the current time in Unix milliseconds and send it in orderly-timestamp. The server rejects requests whose timestamp is more than 300 seconds away from server time.
4. Build the signing message
Concatenate the following fields, without separators:
Timestamp in milliseconds, such as
1649920583000.HTTP method in uppercase, such as
POST.Request path and query string, without the base URL, such as
/v1/orders?symbol=PERP_BTC_USDC.If the request has a body, append its JSON string.
For example:
The serialized body used to create the signature must be the same body sent with the request. Include the query string in the same order and form used in the final URL.
5. Sign the message
Sign the UTF-8 bytes of the normalized message with the Ed25519 private key. Encode the signature using Base64 URL-safe encoding and send it in orderly-signature.
6. Set the content type
Use the content type that matches the HTTP method:
7. Send the request
Once the signature is ready, send the request with the required headers below. The timestamp, HTTP method, request path, query string, and serialized body must match the values used to create the signature.
Content-Type — use application/x-www-form-urlencoded for GET and DELETE requests, and application/json for POST and PUT requests.
orderly-account-id — the registered account ID.
orderly-key — the registered public API key.
orderly-signature — the Ed25519 signature encoded with Base64 URL-safe encoding.
orderly-timestamp — the request timestamp in Unix milliseconds.
The public key string may include the ed25519: prefix, as in ed25519:<base58-public-key>. When a signer helper expects raw key bytes, pass the key without that display prefix. Keep the private key local; never send it with the request.
Security checks
Every authenticated request must pass all four checks below.
Request timestamp
The request is rejected when orderly-timestamp differs from the API server time by more than 300 seconds.
Signature verification
orderly-signature must be a valid Ed25519 signature of the normalized request content, created with the private key associated with the registered public key.
API key validity
The orderly-key value must identify a key that has been registered, is associated with the account in orderly-account-id, and has not expired.
Scope authorization
The key must include the scope required by the endpoint. Use read for private account-data endpoints and trading for order and trading endpoints. These permissions are independent: read does not grant trading access, and trading does not grant read access. Integrations that need both private account data and trading actions should register a key with read,trading.
Minimal TypeScript example
This single-file example signs and sends a testnet market order. Store a real secret securely; the placeholder below is for illustration only.
Method
Content-Type
GET, DELETE
application/x-www-form-urlencoded
POST, PUT
application/json
7. Send the request headers
Content-Type
Content type for the selected method.
orderly-account-id
Account ID associated with the request.
orderly-key
Registered public key, Base58 encoded with the ed25519: prefix.
orderly-signature
Ed25519 signature of the normalized request, Base64 URL-safe encoded.
orderly-timestamp
Request timestamp in milliseconds.
TypeScript example
This example signs and sends a market order from a PangoPerps account. Store the secret outside source code, such as in a server-side environment variable.
Python example
This example uses requests, base58, and the cryptography package. Compact JSON is used so the body included in the signing message is exactly the body sent over HTTP.
Java example
The example below shows the main steps with OkHttp and the net.i2p.crypto.eddsa Ed25519 implementation. The API key secret is read from the environment. Use a Base58 utility supported by your Java project to decode the secret and encode the public key.
Base58.decode and Base58.encode above stand for the Base58 codec used by your Java application.
cURL request template
Generate the timestamp, public key, and signature with your signing code, then insert them into the request. A signature is specific to the request contents and timestamp, so the placeholder below is not a reusable signature.
Request checks
An authenticated request is accepted only when each of these checks succeeds:
Timestamp
The value in orderly-timestamp must be within 300 seconds of the API server’s current time.
Signature
The orderly-signature value must be a valid Ed25519 signature of the normalized request string, created with the private key paired with the supplied public key.
Key status
The public key sent in orderly-key must be registered to the account and must not have expired or been revoked.
Scope
The API key must include the scope needed by the endpoint. Use read for private account data and trading for trading actions. The permissions are independent: one does not imply the other. An integration that reads private account data and also trades needs both read and trading scopes.
Last updated