> For the complete documentation index, see [llms.txt](https://support.power.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.power.trade/api/authentication.md).

# API Authentication | Secure Access to PowerTrade Trading API

All private endpoints require a valid access token.

## Generate an API Key and Private Key[​](https://api-docs-5180b.web.app/docs/authentication#generate-an-api-key-and-private-key)

* Create an account on the [Power Trade's web application](https://app.power.trade/api-keys).
* In the account profile menu in the top right and choose `API Keys`
* The resulting API Key `api_key` and Private key `private_key` can be used to generate a JWT.

## Generate an access token - JWT[​](https://api-docs-5180b.web.app/docs/authentication#generate-an-access-token---jwt) <a href="#generate-an-access-token---jwt" id="generate-an-access-token---jwt"></a>

Use the `ES256` algorithm and add `{client: "api"}` to the payload when generating the token `jwt_token`.

**Example in python**

Using [PyJWT](https://pyjwt.readthedocs.io/en/stable/)

```python
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](https://github.com/kjur/jsrsasign)

```javascript
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:** <support@power.trade>

**Telegram:** <https://t.me/power_trade>

\\
