Private Endpoints
Last updated
Was this helpful?
Was this helpful?
{"e":"54ccea1a-16fd-469c-8018-84b375243e8a","o":"b21f6fd8-b9d1-4b9f-bb79-ef141e3dcb76","ba":"a1b2c3d4-...","qa":"078dcd98-928d-479f-8110-ff6d27e44de2","s":"BUY","am":50}1712500000POST/orders/market{"e":"54ccea1a-16fd-469c-8018-84b375243e8a","o":"b21f6fd8-b9d1-4b9f-bb79-ef141e3dcb76","ba":"a1b2c3d4-...","qa":"078dcd98-928d-479f-8110-ff6d27e44de2","s":"BUY","am":50}dGVzdF9zZWNyZXRfMTIzNDU2Nzgk7Hj9xQ2mN4pL1rT5vW8yB3cF6gJ0sD_eI2uA4wK7ZoOUTPOLL-API-KEY: op_k_abc123
OUTPOLL-API-SIGNATURE: k7Hj9xQ2mN4pL1rT5vW8yB3cF6gJ0sD_eI2uA4wK7Zo
OUTPOLL-API-TIMESTAMP: 1712500000API_KEY='op_k_abc123'
API_SECRET='dGVzdF9zZWNyZXRfMTIzNDU2Nzg'
TIMESTAMP='1712500000'
METHOD='POST'
PATH='/orders/market'
BODY='{"e":"54ccea1a-16fd-469c-8018-84b375243e8a","o":"b21f6fd8-b9d1-4b9f-bb79-ef141e3dcb76","ba":"a1b2c3d4-...","qa":"078dcd98-928d-479f-8110-ff6d27e44de2","s":"BUY","am":50}'
MESSAGE="${TIMESTAMP}${METHOD}${PATH}${BODY}"
SECRET_B64="$(printf '%s' "$API_SECRET" | tr '_-' '/+' | awk '{ n = length($0) % 4; if (n == 2) printf "%s==", $0; else if (n == 3) printf "%s=", $0; else printf "%s", $0 }')"
SECRET_HEX="$(printf '%s' "$SECRET_B64" | base64 -d | xxd -p -c 256)"
SIGNATURE="$(
printf '%s' "$MESSAGE" \
| openssl dgst -sha256 -mac HMAC -macopt "hexkey:$SECRET_HEX" -binary \
| openssl base64 -A \
| tr '+/' '-_' \
| tr -d '='
)"
curl -X POST "https://order-service.outpoll.com${PATH}" \
-H "Content-Type: application/json" \
-H "OUTPOLL-API-KEY: ${API_KEY}" \
-H "OUTPOLL-API-SIGNATURE: ${SIGNATURE}" \
-H "OUTPOLL-API-TIMESTAMP: ${TIMESTAMP}" \
--data "$BODY"import base64, hashlib, hmac, json, time, requests
API_KEY = "op_k_abc123"
API_SECRET = "dGVzdF9zZWNyZXRfMTIzNDU2Nzg"
HOST = "https://order-service.outpoll.com"
PATH = "/orders/market"
BODY = {
"e": "54ccea1a-16fd-469c-8018-84b375243e8a",
"o": "b21f6fd8-b9d1-4b9f-bb79-ef141e3dcb76",
"ba": "a1b2c3d4-...",
"qa": "078dcd98-928d-479f-8110-ff6d27e44de2",
"s": "BUY",
"am": 50,
}
body = json.dumps(BODY)
timestamp = str(int(time.time()))
message = timestamp + "POST" + PATH + body
secret_padded = API_SECRET + "=" * (4 - len(API_SECRET) % 4) if len(API_SECRET) % 4 else API_SECRET
secret_bytes = base64.urlsafe_b64decode(secret_padded)
signature = base64.urlsafe_b64encode(
hmac.new(secret_bytes, message.encode(), hashlib.sha256).digest()
).decode().rstrip("=")
response = requests.post(
HOST + PATH,
headers={
"OUTPOLL-API-KEY": API_KEY,
"OUTPOLL-API-SIGNATURE": signature,
"OUTPOLL-API-TIMESTAMP": timestamp,
"Content-Type": "application/json",
},
data=body,
timeout=10,
)
print(response.status_code, response.text)import crypto from "node:crypto";
const apiKey = "op_k_abc123";
const apiSecret = "dGVzdF9zZWNyZXRfMTIzNDU2Nzg";
const host = "https://order-service.outpoll.com";
const path = "/orders/market";
const body = JSON.stringify({
e: "54ccea1a-16fd-469c-8018-84b375243e8a",
o: "b21f6fd8-b9d1-4b9f-bb79-ef141e3dcb76",
ba: "a1b2c3d4-...",
qa: "078dcd98-928d-479f-8110-ff6d27e44de2",
s: "BUY",
am: 50,
});
const timestamp = String(Math.floor(Date.now() / 1000));
const message = timestamp + "POST" + path + body;
const secret = Buffer.from(
apiSecret + "=".repeat((4 - apiSecret.length % 4) % 4),
"base64url",
);
const signature = crypto
.createHmac("sha256", secret)
.update(message)
.digest("base64url");
const response = await fetch(host + path, {
method: "POST",
headers: {
"OUTPOLL-API-KEY": apiKey,
"OUTPOLL-API-SIGNATURE": signature,
"OUTPOLL-API-TIMESTAMP": timestamp,
"Content-Type": "application/json",
},
body,
});
console.log(response.status, await response.text());import hmac, hashlib, base64, time, json, requests
SERVICE_MAP = {
"/api/events": "https://event-service.outpoll.com",
"/api/categories": "https://event-service.outpoll.com",
"/api/tags": "https://event-service.outpoll.com",
"/api/coins": "https://wallet-mutator-view.outpoll.com",
"/api/user-balances": "https://wallet-mutator-view.outpoll.com",
"/api/history": "https://history-service.outpoll.com",
"/orders": "https://order-service.outpoll.com",
"/auth": "https://auth-service.outpoll.com",
}
class OutpollClient:
def __init__(self, api_key: str, api_secret: str):
self.api_key = api_key
self.api_secret = api_secret
def _host(self, path: str) -> str:
for prefix, host in SERVICE_MAP.items():
if path.startswith(prefix):
return host
return "https://event-service.outpoll.com"
def _sign(self, method: str, path: str, body: str = "") -> dict:
timestamp = str(int(time.time()))
message = timestamp + method + path + body
padded = self.api_secret + "=" * (4 - len(self.api_secret) % 4) if len(self.api_secret) % 4 else self.api_secret
secret_bytes = base64.urlsafe_b64decode(padded)
signature = base64.urlsafe_b64encode(
hmac.new(secret_bytes, message.encode(), hashlib.sha256).digest()
).decode().rstrip("=")
return {
"OUTPOLL-API-KEY": self.api_key,
"OUTPOLL-API-SIGNATURE": signature,
"OUTPOLL-API-TIMESTAMP": timestamp,
"Content-Type": "application/json",
}
def get(self, path: str, params: dict = None):
headers = self._sign("GET", path)
return requests.get(self._host(path) + path, headers=headers, params=params)
def post(self, path: str, data: dict = None):
body = json.dumps(data) if data else ""
headers = self._sign("POST", path, body)
return requests.post(self._host(path) + path, headers=headers, data=body)
def delete(self, path: str):
headers = self._sign("DELETE", path)
return requests.delete(self._host(path) + path, headers=headers)