← Tous les guides

Démarrage rapide : votre premier appel à l'API MotoGP

Abonnez-vous sur RapidAPI, envoyez deux en-têtes et lisez le classement actuel du championnat MotoGP en curl, JavaScript ou Python.

5 min de lecture

Ce guide vous mène de zéro à une requête fonctionnelle en cinq minutes environ. Il vous faut un compte RapidAPI et un terminal.

1. S’abonner et copier votre clé

  1. Ouvrez l’API MotoGP sur RapidAPI et choisissez une offre.
  2. Dans le playground RapidAPI, copiez la valeur de X-RapidAPI-Key. Cette clé identifie votre abonnement ; RapidAPI y rattache votre quota.

Stockez la clé dans une variable d’environnement plutôt que de la coller dans le code :

export RAPIDAPI_KEY="paste-your-key-here"

2. Envoyer votre première requête

Chaque requête nécessite deux en-têtes : votre clé et l’hôte de l’API.

curl -s "https://motogp-api-championship-data-statistics.p.rapidapi.com/standings/seasons/2026/riders?category=MOTOGP" \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: motogp-api-championship-data-statistics.p.rapidapi.com"

La réponse est le championnat pilotes MotoGP 2026, déjà classé par position :

{
  "data": [
    {
      "position": 1,
      "total_points": 365,
      "wins": 6,
      "podiums": 6,
      "season_year": 2026,
      "rider_name": "Marc Márquez",
      "rider_number": 93,
      "team_name": "Ducati Lenovo Team",
      "category": "MOTOGP"
    }
  ],
  "meta": { "total": 32, "page": null, "size": null, "total_pages": null }
}

3. Ne codez pas la saison en dur

GET /seasons/latest renvoie la saison la plus récente : votre code continue donc de fonctionner quand un nouveau championnat commence. Enchaînez-le avec l’appel au classement :

JavaScript (Node.js 18+)

const HOST = "motogp-api-championship-data-statistics.p.rapidapi.com";
const headers = {
  "X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
  "X-RapidAPI-Host": HOST,
};

async function get(path) {
  const res = await fetch(`https://${HOST}${path}`, { headers });
  const body = await res.json();
  if (!res.ok) throw new Error(`${res.status} ${body.message ?? res.statusText}`);
  return body.data;
}

const season = await get("/seasons/latest");
const standings = await get(`/standings/seasons/${season.year}/riders?category=MOTOGP`);

for (const row of standings.slice(0, 5)) {
  console.log(`${row.position}. ${row.rider_name} (#${row.rider_number}) – ${row.total_points} pts`);
}

Python

import os
import requests

HOST = "motogp-api-championship-data-statistics.p.rapidapi.com"
HEADERS = {"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"], "X-RapidAPI-Host": HOST}


def get(path: str, **params):
    res = requests.get(f"https://{HOST}{path}", headers=HEADERS, params=params, timeout=10)
    res.raise_for_status()
    return res.json()["data"]


season = get("/seasons/latest")
standings = get(f"/standings/seasons/{season['year']}/riders", category="MOTOGP")

for row in standings[:5]:
    print(f"{row['position']}. {row['rider_name']} (#{row['rider_number']}) – {row['total_points']} pts")

Sortie :

1. Marc Márquez (#93) – 365 pts
2. Jorge Martín (#89) – 355 pts
3. Marco Bezzecchi (#72) – 315 pts
...

Étapes suivantes

Guide suivant → Conventions : enveloppe, catégories, pagination et erreurs