API
Getting Started - API Keys
By default, certain routes are available publicly in a rate limited manner with no API key. However, API keys allow you access to all routes with higher limits.
Get an API key by going to https://bitbadges.io/developer.
Start sending requests to the base URL of https://api.bitbadges.io/ with the HTTP header x-api-key. All routes require an API key.
Number Types / Stringified Responses
All requests / responses are stringified before being sent over HTTP to avoid losing precision with big numbers > JavaScript's MAX_SAFE_INTEGER. For how to convert the responses to your desired NumberType (bigint, JS number, etc), please see Number Type Conversions from the SDK. We recommend using the JavaScript bigint type.
Note: this is all handled for you if you use the BitBadges API SDK.
Quickstart
See the quickstart repo for a fully configured example repository with fetching collections, accounts, and more with the API!
Routes Documentation
See the documentation for all routes at https://bitbadges.stoplight.io/docs/bitbadges
Testnet Mode
A testnet version of the API is available with the base URL https://api.bitbadges.io/testnet. Everything else is the same, just add the /testnet before all paths. Note that this testnet API is an entirely separate service from normal API. Nothing carries over. It commmunicates with the frontend with testnet mode turned on and uses the testnet BitBadges blockchain.
Using the API SDK (Recommended)
If you are using JavaScript / TypeScript, consider using the typed API SDK for convenience. This will give you typed routes, provide quality checks, and also auto-convert all responses to your desired number type (bigint, Number, etc).
Using BitBadges JS/SDK
Check out the BitBadges JS/SDK for implementing further functionality beyond just API requests / responses, such as manipulating balances, handling approvals, checking permissions, etc.
⚒️BitBadges JS / SDKBitBadges API Authorization
For most applications, you should be fine without needing to access private user authenticated information. This is typically only needed by the official BitBadges frontend.
Otherwise, check out Sign In with BitBadges. This follows a standard OAuth 2.0 flow.
🖱️Sign In with BitBadgesConfined Responses
IMPORTANT: Remember that each retrieval is confined to what is stipulated in the query options. It is your responsibility to append the data to your previous responses as you need. The Tutorials and Concepts will be extremely beneficial to help you deal with this.
Bookmarking
Throughout the API, we use a bookmark technique. For the first request, you will not need to specify a bookmark (e.g. ""), and it will fetch the first page. Within the response, it will return a bookmark and hasMore. hasMore defines whether there are more pages to be fetched. To fetch the next page, you will specify the returned bookmark from the previous request to the next request. This process can be repeated until all are loaded.
Status Codes
We use standard HTTP error codes. 200 is the success code. All errors should follow the ErrorResponse type.
Tutorials
TutorialsLast updated