Overview

The 8Pay REST API provides developers with a straightforward and efficient way to retrieve information about operations performed on the blockchain. While the API allows for reading data, it does not support sending payments, creating recurring payments, or other blockchain interactions, which require direct interaction with the blockchain through a wallet or utilizing the 8Pay JavaScript SDK.

Authentication

To access the 8Pay REST API, developers need to authenticate their requests using an API key that can be generated in the API Keys section.

The API key should be included in the Headers section of the HTTP request using the format:

Authorization: Bearer [API KEY]

Base URL

The base URL for making API requests is:

https://api.8pay.network/v1/:chain/

The :chain parameter in the base URL is a placeholder that should be replaced with the desired chain identifier when making API requests. Depending on the specific chain you want to interact with, you would replace :chain with one of the supported chain identifiers:

  • bsc (BNB Chain)

  • ethereum (Ethereum)

  • sandbox (BNB Chain Testnet)

Pagination

API endpoints returning lists of objects can have a lot of items and are thus paginated.

Pagination can be controlled passing the following query parameters in your HTTP request:

  • limit: the number of items to fetch in the request (default 100, max 1000)

  • offset: an arbitrary offset at which to start retrieving items (default 0)

The formatting of a paginated result is always:

{
    "data": [],
    "limit": 100,
    "offset": 0,
    "total": 10
}

For simplicity, only the data field will be shown from now on.

Errors

8Pay uses conventional HTTP response codes to indicate the success or failure of an API request.

As a general rule:

  • Codes in the 2xx range indicate success

  • Codes in the 4xx range indicate incorrect or incomplete parameters (e.g., a required parameter was omitted, an operation failed with a 3rd party, etc.)

  • Codes in the 5xx range indicate an error with 8Pay's servers (these are rare)

8Pay also outputs an error message and an error code formatted in JSON:

{
    "error": {
        "code": 404,
        "message": "Page not found"
    }
}

Transactions

Every operation on the blockchain is performed sending a transaction, uniquely identified by an hash. This identifier will be referred to as transactionHash in API responses.

Due to blockchain nature, the results produced by a transaction included in a block are not immediately final and can be reverted if a reorganization occurs. Finality is probabilistic and increases with the number of subsequent blocks mined after the block containing the transaction.

8Pay waits for a certain number of blocks depending on the chain before considering transactions confirmed:

  • BNB Chain: 15 blocks

  • Ethereum: 12 blocks

This status is referred to as transactionStatus.

At this time, the public APIs only support confirmed transactions.

Last updated