reunion_get_european_2024
Retrieve final aggregated results of the 2024 European Parliament elections for La Réunion, including voting stats and list details.
Instructions
Final results of the European Parliament elections held on June 9, 2024 (single round) aggregated for département 974 (La Réunion). France elects 81 MEPs from a single national constituency, but this dataset shows how Réunion voters behaved as a department. Returns base voting stats (registered, voters, abstentions, blank, null, expressed) and an array of all 38 lists with panel number, political nuance, list name and abbreviated name, vote count, % of registered/expressed, seats won (national-level allocation reflected here). Sorted by vote count descending.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Handler function for reunion_get_european_2024 tool. Queries data.gouv.fr tabular API for European 2024 election results filtered to département 974, returns base voting stats (registered, voters, abstentions, blank, null, expressed) plus an array of 38 lists sorted by vote count descending.
server.tool( 'reunion_get_european_2024', 'Final results of the European Parliament elections held on June 9, 2024 (single round) aggregated for département 974 (La Réunion). France elects 81 MEPs from a single national constituency, but this dataset shows how Réunion voters behaved as a department. Returns base voting stats (registered, voters, abstentions, blank, null, expressed) and an array of all 38 lists with panel number, political nuance, list name and abbreviated name, vote count, % of registered/expressed, seats won (national-level allocation reflected here). Sorted by vote count descending.', {}, async () => { try { const data = await dataGouvClient.query<Row>(RES_EUROP_2024_DEPT, { filters: { 'Code département': '974' }, pageSize: 5, }); const row = data.data[0]; if (!row) { return errorResult('No data returned for département 974 in European 2024 dataset'); } return jsonResult({ source: 'data.gouv.fr (Ministère de l\'Intérieur)', election: 'européennes 2024', department: str(row['Libellé département']), ...mapBaseStats(row), lists: meltLists(row), }); } catch (error) { return errorResult(error instanceof Error ? error.message : 'Failed to fetch European 2024'); } } ); - src/modules/national-elections.ts:164-189 (registration)Registration of the reunion_get_european_2024 tool via server.tool() inside registerNationalElectionsTools().
server.tool( 'reunion_get_european_2024', 'Final results of the European Parliament elections held on June 9, 2024 (single round) aggregated for département 974 (La Réunion). France elects 81 MEPs from a single national constituency, but this dataset shows how Réunion voters behaved as a department. Returns base voting stats (registered, voters, abstentions, blank, null, expressed) and an array of all 38 lists with panel number, political nuance, list name and abbreviated name, vote count, % of registered/expressed, seats won (national-level allocation reflected here). Sorted by vote count descending.', {}, async () => { try { const data = await dataGouvClient.query<Row>(RES_EUROP_2024_DEPT, { filters: { 'Code département': '974' }, pageSize: 5, }); const row = data.data[0]; if (!row) { return errorResult('No data returned for département 974 in European 2024 dataset'); } return jsonResult({ source: 'data.gouv.fr (Ministère de l\'Intérieur)', election: 'européennes 2024', department: str(row['Libellé département']), ...mapBaseStats(row), lists: meltLists(row), }); } catch (error) { return errorResult(error instanceof Error ? error.message : 'Failed to fetch European 2024'); } } ); - src/modules/index.ts:47-56 (registration)Tool module registration entry point — registerNationalElectionsTools is called from registerAllTools.
registerNationalElectionsTools(server); registerPossessionTools(server); registerSocialTools(server); registerTelecomTools(server); registerTerritoryTools(server); registerTourismTools(server); registerTransportTools(server); registerUrbanismTools(server); registerWeatherTools(server); } - meltLists helper — extracts up to 38 list entries from the wide-format row into a clean array sorted by vote count.
function meltLists(row: Row, maxN = 38) { const out = []; for (let i = 1; i <= maxN; i++) { const name = str(row[`Libellé de liste ${i}`]); if (!name) continue; out.push({ panel: num(row[`Numéro de panneau ${i}`]), nuance: str(row[`Nuance liste ${i}`]), list_name: name, list_short: str(row[`Libellé abrégé de liste ${i}`]), votes: num(row[`Voix ${i}`]), pct_registered: str(row[`% Voix/inscrits ${i}`]), pct_expressed: str(row[`% Voix/exprimés ${i}`]), seats: num(row[`Sièges ${i}`]), }); } return out.sort((a, b) => (b.votes ?? 0) - (a.votes ?? 0)); } - mapBaseStats helper — extracts base voting statistics (registered, voters, abstentions, blank, null, expressed) from the raw row.
function mapBaseStats(row: Row) { return { registered: num(row.Inscrits), voters: num(row.Votants), pct_voters: str(row['% Votants']), abstentions: num(row.Abstentions), pct_abstentions: str(row['% Abstentions']), expressed: num(row.Exprimés), blank: num(row.Blancs), null_votes: num(row.Nuls), }; }