Code Samples

The Odds API is easy to use with your favorite coding language. We've included simple Python and Node.js code examples to help you get started.

Be sure to specify your api key in order for the examples to work. If you need an API key, get one from here for free.

For details on the api, see the quickstart guide.

Python

Note
This example uses python's requests library, which can be installed with
pip install requests

Security Tip for Repl.it users
This example uses Repl.it* to run live code. If you continue coding using a free Repl.it account, anyone visiting your Repl.it repo might see your api key.

To make sure it stays secret, create a file called .env containing api_key=YOUR_API_KEY
Back in main.py, bring in your api key with:
import os
api_key = os.getenv("api_key")

For more info, see the Repl.it docs.

Node.js

Note
This example uses Node's axios library, which can be installed with
npm install axios or bower install axios

Security Tip for Repl.it users
This example uses Repl.it* to run live code. If you continue coding using a free Repl.it account, anyone visiting your Repl.it repo might see your api key.

To make sure it stays secret, create a file called .env containing api_key=YOUR_API_KEY
Back in index.js, bring in your api key with:
const api_key = process.env.api_key

For more info, see the Repl.it docs.