Guides2 min read

How to authenticate: API keys vs JWT

Use an API key for servers or a JWT for user sessions. See how to authenticate your requests.

cryptoapi team
Guides
On this page

Use your dashboard API key for backend integrations or a JWT for user sessions. The public network catalogue is available through GET /public/networks.

bash
curl "https://api.cryptoapi.so/public/networks"

The response lists network names and slugs. Authenticated routes live under /api/.

Option A: API keys (best for server-to-server)

Create an API key in your dashboard. Pass it in the key header from your server.

bash
curl "https://api.cryptoapi.so/api/info/gas?network=ethereum" \
  --header "key: $CRYPTOAPI_KEY"

A successful request includes fee estimates under data. The legacy query-string method can expose credentials in URLs and access logs.

Option B: JWT Bearer (best for user/browser sessions)

When a real user signs in, exchange their credentials for a JWT and send it as a Bearer token. Get the token from the login endpoint:

bash
curl -X POST "https://api.cryptoapi.so/public/user/login" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "password": "your-password"}'

Then attach the returned token to authenticated calls:

bash
curl -X POST "https://api.cryptoapi.so/api/wallet/balance" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{"network": "ethereum", "address": "0xYourAddress"}'

JWTs are ideal for dashboards and user-facing apps where each person acts as themselves. API keys are better for backend jobs and integrations that run without a logged-in user.

Security best practices

  • Keep API keys server-side. Never ship a key in client-side JavaScript, a mobile bundle, or a public repo. Anyone who reads it can spend your quota.
  • For browser apps, proxy requests through your own backend, which holds the key, or use a per-user JWT instead.
  • Prefer the key header to the ?key= query parameter to reduce where the secret gets logged.
  • Rotate keys you suspect are exposed and use distinct keys per environment so you can revoke one without breaking the rest.

One last note that makes auth simpler here: CryptoAPI is non-custodial. Your CryptoAPI credentials authorize API calls. Keep wallet keys in your signing software.

Get started

Grab an API key from your dashboard, drop it in the key header, and you are ready to query balances, transactions, and more across Ethereum, BNB Smart Chain, Bitcoin, and Tron. Full reference lives at https://api.cryptoapi.so/api/doc.

Read it, then ship it

Copy the code above and run it today.

Every snippet in this guide works on the free plan. Grab a key and make your first call in a minute.