# Quickstart

Three steps: get a key, make a call, read the result. You need nothing installed except a terminal or a language you already use.

## 1. Get your key

[Sign up](https://onekey.dev/signup) for a free key, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack. Your key looks like `ok_live_...` and is shown once, so copy it when it appears. In the snippets below, replace `YOUR_API_KEY` with it.

## 2. Make your first call

This looks up **github.profile**: Fetch a GitHub user's public profile. It costs 1 credit. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

```bash
curl "https://api.onekey.dev/v1/github/profile?username=torvalds" \
  -H "x-api-key: YOUR_API_KEY"
```

```python
import requests

res = requests.get(
    "https://api.onekey.dev/v1/github/profile",
    params={"username": "torvalds"},
    headers={"x-api-key": "YOUR_API_KEY"},
)
body = res.json()

if body["success"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
```

```javascript
const params = new URLSearchParams({ username: "torvalds" });
const res = await fetch(`https://api.onekey.dev/v1/github/profile?${params}`, {
  headers: { "x-api-key": "YOUR_API_KEY" },
});
const body = await res.json();

if (body.success) console.log(body.data);
else console.error(body.error.code, body.error.message);
```

## 3. Read the result

You get the standard response. Your data is in `data`, and what the call cost is in `metadata.credits_charged`.

```json
{
  "success": true,
  "data": { "...": "unified fields for this endpoint" },
  "metadata": { "cached": false, "credits_charged": 1, "request_id": "7f3a9c2e5b1d4c8fa2e6d0b9c4f18e37" },
  "error": null
}
```

Always check `success` before you use `data`. On failure it is `false`, `data` is `null`, and `error` explains why. The same call twice in a row is served from cache and is free.

## Check your key without spending credits

`GET /v1/account` returns your balance and never costs credits:

```bash
curl "https://api.onekey.dev/v1/account" \
  -H "x-api-key: YOUR_API_KEY"
```

> [!TIP] Store the key in an environment variable such as `ONEKEY_KEY` and read it from there. Never put it in browser code or a public repo.

## Next

- Try other platforms in the [catalog](https://onekey.dev/docs/platforms.md): change the two path words, keep your code.
- Have a link instead? `GET /v1/lookup?url=https://github.com/facebook/react` resolves it to the right endpoint for you. See [URL lookup](https://onekey.dev/docs/lookup.md).
- Need several records, or one query on several platforms? See [Batch](https://onekey.dev/docs/batch.md) and [Multi-platform search](https://onekey.dev/docs/search-multi.md).
- Understand the [response format](https://onekey.dev/docs/response-envelope.md).
- See what can go wrong in [Errors](https://onekey.dev/docs/errors.md).
