Authentication
All private endpoints require a valid access token.
Generate an API Key and Private Key
Create an account on the Power Trade's web application.
In the account profile menu in the top right and choose
API KeysThe resulting API Key
api_keyand Private keyprivate_keycan be used to generate a JWT.
Generate an access token - JWT
Use the ES256 algorithm and add {client: "api"} to the payload when generating the token jwt_token.
Example in python
Using PyJWT
def generate_access_token(api_key, private_key):
now = utils.time.time_s()
return jwt.encode({"exp": now + 60, "iat": now,
"sub": api_key, "client": "api"}, private_key, algorithm="ES256")Example in Node.js
Using jsrsasign
import rs from "jsrsasign";
const header = { alg: "ES256", typ: "JWT" };
const payload = {
sub: api_key,
iat: rs.KJUR.jws.IntDate.get("now"),
exp: getUnixTime(add(Date.now(), { days: 10 })),
client: "api",
nonce: getUnixTime(Date.now()),
};
const headerString = JSON.stringify(header);
const payloadString = JSON.stringify(payload);
return rs.KJUR.jws.JWS.sign("ES256", headerString, payloadString, private_key);Web Based JWT builder
If you want a quick way to verify that your API Key is working, you can also use our web based jwt builder:
https://app.power.trade/jwt-builder
Still have questions?
Email Support: [email protected]
Telegram: https://t.me/power_trade
Last updated
Was this helpful?