Code Samples V4
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. Get a free API key here.
For more details, see the API docs. Code samples are also available on Github
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:
python
import os
api_key = os.getenv("api_key")For more info, see the Repl.it docs
This code sample can also be found on Github
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:
js
const api_key = process.env.api_keyFor more info, see the Repl.it docs
This code sample can also be found on Github