← 모든 가이드

빠른 시작: 첫 MotoGP API 호출

RapidAPI에서 구독하고 헤더 두 개를 보내 현재 MotoGP 챔피언십 순위를 curl, JavaScript 또는 Python으로 가져옵니다.

5분 분량

이 가이드는 약 5분 안에 처음부터 동작하는 요청까지 안내합니다. RapidAPI 계정과 터미널이 필요합니다.

1. 구독하고 키 복사하기

  1. RapidAPI의 MotoGP API를 열고 플랜을 선택합니다.
  2. RapidAPI 플레이그라운드에서 X-RapidAPI-Key 값을 복사합니다. 이 키가 구독을 식별하며, RapidAPI는 이 키를 기준으로 할당량을 계산합니다.

키를 코드에 붙여 넣지 말고 환경 변수에 저장하세요.

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

2. 첫 요청 보내기

모든 요청에는 키와 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"

응답은 2026 시즌 MotoGP 라이더 챔피언십이며, 이미 순위순으로 정렬되어 있습니다.

{
  "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. 시즌을 하드코딩하지 마세요

GET /seasons/latest는 가장 최근 시즌을 반환하므로, 새 챔피언십이 시작되어도 코드가 계속 동작합니다. 순위 호출과 이어서 사용하세요.

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")

출력:

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

다음 단계

다음 가이드 → 규칙: 엔벨로프, 카테고리, 페이징, 오류