Skip to main content

How to pass the API key

The new API (https://data.anysport.io/v1/soccer) supports only one method: pass it in the HTTP request header, using the fixed header name apikey (all lowercase, no X- prefix), with the value being your API key itself.
⚠️ Difference from the legacy version (breaking change): the legacy api.anysport.io supported either the X-API-Key header or the ?api_key= query parameter. The new version no longer accepts a key passed via any query parameter (?api_key=/?apikey= are both invalid), and no longer uses the X-API-Key header name. Only the apikey header is recognized — a missing header, an incorrect header name (e.g. still using X-API-Key), or passing the key in a URL query parameter will all be treated as unauthenticated and return 401 UNAUTHORIZED. When migrating, check your code for any remaining use of query-parameter key passing.

Code examples

Getting an API key

  1. Go to dashboard.anysport.io and sign up for an account.
  2. Verify the 6-digit code sent to your email.
  3. After logging in, your API key is displayed directly on the dashboard home page and can be copied at any time.
Each subscription plan has its own separate API key. If you hold multiple subscriptions, each key corresponds to its own plan permissions and usage quota.

Regenerating your API key

You can regenerate your API key at any time from the dashboard. The old key is invalidated immediately. The new key is always visible on the dashboard and can be copied at any time.

Security best practices

  • Never commit your API key to a code repository (e.g. Git).
  • Store the key in environment variables (a .env file) rather than hardcoding it in your code.
  • If you suspect your key has been leaked, regenerate it immediately.
  • Do not expose the key in publicly accessible client-side JavaScript code.
  • Do not append the key to URL query parameters (the new version doesn’t support this method anyway) — URLs are more easily captured in server access logs, browser history, proxy caches, and other intermediate points.

Error responses