2020 US Presidential Election - EOS

If you want to connect to the full AP Election results in any language over HTTP, learn how here.

Note that the EOS race calls contain more than just the presidential results. This smart contract contains presidential, house, senate, and governor race calls.

Walkthrough

  1. Fetching EOS Oracle data is a simple HTTP request. Use fetch or your favorite library to make the request

    // in JavaScript
    const allWinners = await fetch('https://eos.hyperion.eosrio.io/v2/history/get_actions?limit=1&account=associapress&filter=associapress%3Aelection&sort=desc')
        .then((res) => res.json())
        .then((res) => {
            return res?.actions?.[0]?.act?.data?.data;
        })
        .then((res) => JSON.parse(res));

2. View the raw JSON response here to ensure you're accessing the data you're interested in:

3. Still having issues?‌

  1. ​Ensure you're accessing the exact part of the JSON object you're interested in. If you want to use the data field as JSON, you have to stringify it first (the code example in #1 above already does this properly)

  2. Tweet to @dawsonbotsford and @everipedia any engineering questions (or send a DM on Twitter to @dawsonbotsford)

Last updated