> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openformat.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# API Overview

> In this page you will learn how to work with the the OPENFORMAT API

## 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.

```curl theme={null}
--header 'X-API-KEY: <OPENFORMAT_API_KEY>'
```

> [!WARNING]
>
> 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](https://docs.openformat.tech/api-reference/endpoint/api-key/post-keychallenge.md). 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](https://openformat-tools.vercel.app/) for signing messages with Metamask. If you prefer to sign messages locally, you can use the following scripts:

```tsx viem (Recommended) theme={null}
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....

```

```tsx ethers theme={null}
import { ethers } from "ethers";

const privateKey = "YOUR_PRIVATE_KEY";
const wallet = new ethers.Wallet(privateKey);

// Challenge returned from /key/challenge endpoint
const challenge = "7877fa9f42dd92bebfefa7d6469e774327afddf76718e93288182949af7d3ade";

const signed = await wallet.signMessage(challenge);

console.log(signed);
// 0x9fe5ad28c81419f5135aec3c....
```

## Transaction Lifecycle

We recommend reading and understanding the [Transaction Lifecycle](https://docs.openformat.tech/api-reference/architecture/transaction-lifecycle.md) before continuing.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.