Les listes renvoient un objet { data, meta } : data contient les éléments, meta la pagination (total, page, limit, totalPages, hasNext, hasPrev). Identifiez votre client par un User-Agent descriptif et restez sous 10 requêtes par minute (voir Limites & Cache).
💻 Exemples par langage
cURL
Code
# Récupérer les 10 derniers scrutins de l'Assemblée nationalecurl -X GET "https://api.clair.vote/api/v1/scrutins?chambre=assemblee&limit=10" \ -H "User-Agent: MonAppCitoyenne/1.0" \ -H "Accept: application/json"
TypeScript (Fetch)
Code
interface Scrutin { id: string; numero: number; titre: string; sort: string;}async function getDerniersScrutins(): Promise<Scrutin[]> { const res = await fetch("https://api.clair.vote/api/v1/scrutins?limit=10", { headers: { "User-Agent": "MonAppCivique/1.0 (contact@monprojet.org)", }, }); if (!res.ok) { throw new Error(`Erreur HTTP: ${res.status}`); } const data = await res.json(); return data.data;}getDerniersScrutins().then(console.log);
Python (requests)
Code
import requestsurl = "https://api.clair.vote/api/v1/parlementaires"params = {"chambre": "assemblee", "limit": 5}headers = {"User-Agent": "EtudeParlementairePython/1.0"}response = requests.get(url, params=params, headers=headers)response.raise_for_status()deputes = response.json()for d in deputes.get("data", []): groupe = d.get("groupe") groupe_nom = groupe["nom"] if groupe else "Non-inscrit" print(f"{d['prenom']} {d['nom']} - Groupe: {groupe_nom}")