Creating an SDK Pt. 1

I’m currently running a little experiment about sports betting & stock performance. All data in the experiment is currently entered manually, so as a developer of course the next iteration is to automate everything that can be automated. Stock prices data is readily available through many services. Due to its residence in the legal gray area, a free API to fetch betting information does not exist. This presents an interesting opportunity to source & build a SDK to get betting data.

We need to begin with a reliable source of betting information. A lot of variation exists between bookmakers, but due to the nature of this project, we don’t necessarily care about which sportsbook has the “best” odds. We also don’t care about submitting bets, only consuming the data, so that’s not a requirement for any sportsbook we pick. I went with Odds Shark, a sportsbook aggregator. They fit our use case perfectly, and fetch the data for their pages through an AJAX call rather than rendering it server side. We also have an added bonus of seeing multiple sportsbooks to compare!

Finding the endpoints

OddsShark doesn’t have any publicly available API documentation that I know of. We’ll need to figure out what API calls we need. Opening up Chrome’s web inspector, we can track the network calls OddsShark makes on their site. On the home screen, we see a few calls that we’ll probably want to incorporate. The calls and the data shape returned is below.

Ticker - NCAA Basketball


  "leagues": {
    "nfl": false,
    "ncaaf": false,
    "nhl": true,
    "nba": true,
    "ncaab": true,
    "mlb": true
  "matchups": [
      "type": "date",
      "date": {
        "day": "25",
        "fullday": "Saturday",
        "month": "Mar"
      "current": false
      "type": "matchup",
      "event_id": "780805",
      "away_short_name": "FURMN",
      "home_short_name": "CAMBP",
      "away_name": "Furman",
      "home_name": "Campbell",
      "total": "141",
      "away_odds": "-6",
      "home_odds": "6",
      "status": "FINAL",
      "away_score": "79",
      "home_score": "64",
      "trending_total": 143,
      "matchup_link": "/ncaab/furman-campbell-odds-march-25-2017-780805"

In this response (we’ll refer to that as the Ticker call), we receive two top-level keys. "leagues" is good metadata, and gives us some hints as to other tokens we can use in this call to receive data on other sports leagues. "matchups" looks like the data we want - it gives us information on the actual game & information on the odds surrounding the game. However, it looks like this game has been completed which means that the data is largely irrelevant to us. We need to look for something similar, but with Matchups that have yet to be completed so that we can bet on them.

There’s another call that occurs right after the Ticker call above. We’ll refer to this as the Upcoming call.

Upcoming - NCAA Basketball


  "type": "matchups",
  "data": [
      "game_id": "781168",
      "game_date": "2017-03-27 20:30:00",
      "away_team": "Wyoming",
      "away_short_name": "WYOM",
      "away_display_name": "Wyoming",
      "home_team": "Coastal Carolina",
      "home_short_name": "COCAR",
      "home_display_name": "Coastal Carolina",
      "away_votes": 60,
      "home_votes": 40,
      "over_votes": 0,
      "under_votes": 0,
      "total": "154",
      "under_price": "-110",
      "over_price": "-110",
      "home_money_line": "-104",
      "away_money_line": "-116",
      "home_spread": "1",
      "away_spread": "-1",
      "home_spread_price": "-110",
      "away_spread_price": "-110"

The Upcoming Matchup results have some more information that we need. The betting data we want consists of:

  • Under / Over
    • This refers to the total points scored in the game, which is the value for the key total
    • under_price & over_price represent the value of betting that the actual total will be under or over total respectively
  • Moneyline
    • This refers to the outcome of the game regardless of points scored
    • away_money_line & home_money_line represent the value of betting the winner of the game. Here, the away team is more expensive, meaning that it requires more money to get the same payout if betting on the home team
  • Spread
    • This refers to the outcome of the game while handicapping the teams
    • The “spread” is the points to add or deduct from a team’s final score to determine the outcome. Here, the away team has a -1 spread - this means that in order to win this bet, the away team has to win by 2 points of more since the final score has the -1 applied to it.

The values of the bets are presented in a format of +/-. It’s all based on a 100 unit base figure. If a bet value has a -, that is the value required to be bet to win $100. Above, the home_money_line is -104, which means that one would have to bet $104 to win $100. If a bet value has +, that is the value that would be won if one bets $100. If the home_money_line value was +130, that means one would win $130 if they bet $100.

Navigating around with the Chrome Inspector open, it’s easy to find other AJAX calls that we’ll probably want to put into our SDK as well. For the sake of time, I’ve put them below. Feel free to curl request these endpoints to check them out yourself. One caveat about OddsShark’s API endpoints is that the Referer header needs to be set with a endpoint.


  • /upcoming/us/<league>
  • /ticker/<league>
  • /scores/<league>/<YYYY-MM-DD>
  • /gamecenter/<league>
  • /play_by_play/<league>

Next Steps

This project will be built using Elixir. The next step is implementing these endpoints and getting used to the Elixir language.