Como autenticar na API

How to authenticate with the Football API

A autenticacao e feita via query parameter key. Basta adicionar sua chave em cada chamada.

Authentication is done via the key query parameter. Just add your key to each request.

1. Formato da chamada / Request format

Adicione ?key=YOUR_API_KEY (ou &key=YOUR_API_KEY se ja houver parametros) em toda requisicao:

https://football.api.insyde.one/leagues?current=true&key=YOUR_API_KEY

2. Exemplos por linguagem / Examples by language

curl:

curl "https://football.api.insyde.one/leagues?current=true&key=YOUR_API_KEY"

JavaScript (fetch):

const API_KEY = 'YOUR_API_KEY';
const BASE = 'https://football.api.insyde.one';

const res = await fetch(`${BASE}/leagues?current=true&key=${API_KEY}`);
const data = await res.json();

Python (requests):

import requests

API_KEY = "YOUR_API_KEY"
BASE = "https://football.api.insyde.one"

resp = requests.get(f"{BASE}/leagues", params={
    "current": "true",
    "key": API_KEY
})
data = resp.json()

Helper function (reutilizavel / reusable):

async function fetchApi(endpoint, params = {}) {
  params.key = API_KEY;
  const qs = new URLSearchParams(params).toString();
  const res = await fetch(`${BASE}/${endpoint}?${qs}`);
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

// Usage
const data = await fetchApi('leagues', { current: 'true' });

3. Codigos de erro / Error codes

HTTP Code Significado / Meaning O que fazer / What to do
401 Chave invalida ou ausente / Invalid or missing key Verifique se a chave esta correta / Check if the key is correct
429 Rate limit excedido / Rate limit exceeded Aguarde e tente novamente. Adicione delays entre chamadas / Wait and retry. Add delays between calls
499 Cota diaria esgotada / Daily quota exceeded Aguarde o reset diario ou faca upgrade do plano / Wait for daily reset or upgrade plan

4. Tratando erros / Handling errors

async function safeFetch(url) {
  const res = await fetch(url);

  if (res.status === 401) {
    throw new Error('Invalid API key. Check your key parameter.');
  }
  if (res.status === 429) {
    const retryAfter = res.headers.get('retry-after') || 60;
    console.warn(`Rate limited. Retry after ${retryAfter}s`);
    await new Promise(r => setTimeout(r, retryAfter * 1000));
    return safeFetch(url); // retry once
  }
  if (res.status === 499) {
    throw new Error('Daily quota exceeded. Try again tomorrow.');
  }

  return res.json();
}
Seguranca: Nunca exponha sua chave em codigo frontend publico. Use um backend proxy para esconder a chave.
Security: Never expose your key in public frontend code. Use a backend proxy to hide the key.

5. Rate limits por tipo de endpoint / Rate limits by endpoint type

Os limites variam conforme o tipo de dado:

Dica: Monitore o header x-ratelimit-remaining na resposta para saber quantas chamadas restam no minuto.
Tip: Monitor the x-ratelimit-remaining response header to know how many calls remain in the current minute.

Back to Football API docs