0

I am trying to check my Perpetual Swap contracts on Okex Exchange, from the terminal. I am using openssl to make the HMAC SHA256 signature. But so far I am only getting a "code":405," error, and the docs are not very insightful: https://www.okex.com/docs/en/#summary-yan-zheng

I wonder if someone who has more experience with the Okex Rest Api could help with this script?

#!/bin/bash

API_KEY=xxxxxx
API_SECRET=yyyyy
PASSPHRASE=zzzzzzzz

TIMESTAMP=$(date --utc +%FT%T.%3NZ)

TYPE='POST'

ENDPOINT='/api/swap/v3/BTC-USD-SWAP/position'

MESSAGE=$(printf "%s+%s+%s" "$TIMESTAMP" "$TYPE" "$ENDPOINT")

SIGNED_MESSAGE=$(echo -n "$MESSAGE" | openssl dgst -sha256 -hmac $API_SECRET -binary | base64 | tr -d "\n")


curl 'https://www.okex.com' \
--header "Content-Type: application/json" \
--request POST \
--data "\{\"OK-ACCESS-SIGN\":$SIGNED_MESSAGE, \"OK-ACCESS-KEY\":$API_KEY, \"OK-ACCESS-TIMESTAMP\":$TIMESTAMP, \"OK-ACCESS-PASSPHRASE\":$PASSPHRASE\}"

nagualcode
  • 47
  • 6

1 Answers1

0

It's get not post for this call.

GET/api/swap/v3/<instrument_id>/position

TYPE='GET'

Secondly on other calls.. Make sure you add (body) to MESSAGE

--> timestamp + method + requestPath + json_encode(body)

Regards

Jon C.
  • 374
  • 1
  • 4
  • 14