Get your first API key
Create a Starkscan API key and make your first authenticated call in under five minutes.
Get your first API key
One key works across REST, authenticated JSON-RPC beta, the TypeScript SDK, the CLI, and hosted MCP. This page takes you from no key to a successful call.
1. Create a key
- Open the API keys page.
- Sign in (or create an account).
- Create a key and copy both the raw key and the RPC node URL if your software needs a provider URL. You see the full value once — store it in an environment variable or secrets manager. Never paste it into chat, tickets, screenshots, PR comments, or source. Rotate it if the full value ever leaks.
2. Set your environment
export STARKSCAN_CHAIN="SN_MAIN"
export STARKSCAN_API_KEY="<your key>"
# Optional: only set this for preview or self-hosted hosts.
# export STARKSCAN_BASE_URL="https://preview.example.com/api"The hosted CLI, SDK, and MCP launcher default to https://api.starkscan.co.
Set STARKSCAN_BASE_URL only when you are targeting preview or a custom host.
For raw HTTP path details, see Base URLs and chains.
3. Make your first call
curl -H "X-Starkscan-Api-Key: $STARKSCAN_API_KEY" \
"${STARKSCAN_BASE_URL:-https://api.starkscan.co}/v1/$STARKSCAN_CHAIN/status"Success looks like a JSON object with chainId, headBlockNumber, latestIndexedBlockNumber, and lagBlocks.
Use the same key everywhere
| Surface | How |
|---|---|
| REST | Send the X-Starkscan-Api-Key header — see Authentication. |
| JSON-RPC beta | Use https://starkscan.co/rpc/v0_10/SN_MAIN/<starkscan_api_key> when a client only accepts a node URL. Send the same header to POST https://api.starkscan.co/v1/SN_MAIN/rpc when a client can attach headers. For preview or self-hosted deployments, replace the hosted host with your deployment's app/API host before copying these examples. See Starkscan RPC. |
| TypeScript SDK | createStarkscanClient({ apiKey, chainId }) — add baseUrl only for preview or self-hosted hosts; see TypeScript SDK. |
| CLI | npx -y @starkscan/cli ... for default use, or @starkscan/cli@0.1.2 for pinned use — see Agent CLI. |
| MCP | Connect the hosted MCP server — see MCP quickstart. |
RPC beta keys
Self-serve Starkscan API keys work with the authenticated JSON-RPC beta at the
canonical hosted endpoint POST https://api.starkscan.co/v1/SN_MAIN/rpc. The
app-host compatibility shape is POST https://starkscan.co/api/v1/SN_MAIN/rpc.
Use it for standard reads, state/history calls, events, fee/simulation
envelopes, and already-signed transaction forwarding. It requires a Starkscan
API key and does not provide public WSS promotion, broad tracing,
archive/full-history parity, or a full-provider replacement. WSS is a separate
beta route when explicitly enabled and proven for a named client.
For clients that cannot send headers, use the URL-token compatibility path with a dedicated key per app or environment:
- header auth:
POST https://api.starkscan.co/v1/SN_MAIN/rpc - app-host compatibility:
POST https://starkscan.co/api/v1/SN_MAIN/rpc - URL-token
nodeUrl:https://starkscan.co/rpc/v0_10/SN_MAIN/<starkscan_api_key> - support channel: higher batch/concurrency limits or migration-specific proof
For preview or self-hosted deployments, replace starkscan.co and
api.starkscan.co with your deployment's app/API host before copying these
examples. This keeps URL-token secrets on the intended origin.
Treat URL-token nodeUrl values as secrets. Header auth is preferred whenever
your client can send X-Starkscan-Api-Key.
If your first call fails
A 401 means the key is missing or wrong, and a 403 means the key is valid but the route is not in your tier. See Authentication for the full list and fixes.