क्विकस्टार्ट: MotoGP API की आपकी पहली कॉल
RapidAPI पर सब्सक्राइब करें, दो हेडर भेजें और curl, JavaScript या Python में मौजूदा MotoGP चैंपियनशिप स्टैंडिंग्स पढ़ें।
5 मिनट में पढ़ें
यह गाइड आपको लगभग पाँच मिनट में शून्य से काम करने वाले रिक्वेस्ट तक पहुँचाती है। आपको एक RapidAPI अकाउंट और एक टर्मिनल चाहिए।
1. सब्सक्राइब करें और अपनी कुंजी कॉपी करें
- RapidAPI पर MotoGP API खोलें और एक प्लान चुनें।
- RapidAPI प्लेग्राउंड में X-RapidAPI-Key का मान कॉपी करें। यह कुंजी आपके सब्सक्रिप्शन की पहचान है; RapidAPI इसी के आधार पर आपका कोटा गिनता है।
कुंजी को कोड में चिपकाने के बजाय environment variable में रखें:
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
...
अगले कदम
- कैटेगरी, पेजिंग, त्रुटियों और कैशिंग के लिए कन्वेंशन पढ़ें।
- अपनी साइट के लिए स्टैंडिंग्स टेबल बनाएँ।
- सभी endpoints MotoGP API संदर्भ में देखें।