API-Key rate limiting

The following guide covers the creation and usage of Pacifica API-keys.

Pacifica also offers API-Key rate limiting on APIs that allows for more flexible limits. For more information around API-key limits, please reach out to us in the Discord API channel. API-Keys are generated via REST API. The Python SDK provides examples for how API-Key can be generated, listed and revoked: https://github.com/pacifica-fi/python-sdk/blob/main/rest/manage_api_key.py. Each account can have up to five API keys.

POST /api/v1/account/api_keys/create
POST /api/v1/account/api_keys/revoke
POST /api/v1/account/api_keys

Request Body:

Field
Type
Need
Description
Example

"account"

string

required

User's wallet address

42trU9A5...

"signature"

string

required

Cryptographic signature

5j1Vy9Uq...

"timestamp"

integer

required

Current timestamp in milliseconds

1716200000000

"expiry_window"

integer

optional

Signature expiry in milliseconds

30000

{
    "auth": {
      "account": "42trU9A5...",
      "signature": "5j1Vy9Uq...",
      "timestamp": 1716200000000,
    }
}

Response

{
  "data": {
    "api_key": "AbCdEfGh_2mT8x..."
  }
}

Note: API keys are generated with a prefix for fast lookup Format: "{8_char_prefix}_{base58_encoded_uuid}"

Using a Pacifica API-key

Pacifica's API-Keys are used to enhance websocket rate-limiting. The default rate for an API-Key follows the same restrictions as IP-based rate limits. Pacifica API-Keys are used in the connection header to specify API-Key rate limiting. Using the Python SDK as an example,

  • for Websockets, add extra_headers={"PF-API-KEY": "your_rate_limit_key"}into websockets.connect

  • for REST APIs, add "PF-API-KEY": "your_rate_limit_key" into headers with {"Content-Type": "application/json"}

Last updated

Revision created