Authentication
Authentication for the OPENFORMAT API involves the use of an API Key, which is a secure credential that is tied to a specific Ethereum account address. This key should be included in the header of the request.
--header 'X-API-KEY: <OPENFORMAT_API_KEY>'
It is advised not to hardcode your credentials in a file in
production environments. Use environment variables instead.
API Endpoints
OPENFORMAT provides a multitude of API endpoints that enable a variety of functionalities.
the base URL for the the OPENFORMAT API is https://api.openformat.tech.
For instance, to get leaderboard data, the endpoint to use would look like this https://api.openformat.tech/v1/leaderboard.
Generating an API Key
You can generate an API Key in the API Reference. The process involves two steps: challenge and verify. As mentioned, an API Key is associated with a specific Ethereum account address. To achieve this, you must generate a challenge, sign it with your account address, and then verify the signed challenge.
We’ve developed a signing tool for signing messages with Metamask. If you prefer to sign messages locally, you can use the following scripts:
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount("YOUR_PRIVATE_KEY");
// Challenge returned from /key/challenge endpoint
const challenge = "7877fa9f42dd92bebfefa7d6469e774327afddf76718e93288182949af7d3ade";
const signed = await account.signMessage({ message: challenge });
console.log(signed);
// 0x9fe5ad28c81419f5135aec3c....
Transaction Lifecycle
We recommend reading and understanding the Transaction Lifecycle before continuing.