Version: 2.0.0

Results (Push Stream)

REQUIREMENT

You'll need a license key to use OddsJam's API. You can get one by emailing us at [email protected].

API Endpoint#

https://api-external.oddsjam.com/api/v2/stream/results

Parameters#

NOTE

You must provide at least one of game_id or league per GET request.

key (required)#

Your OddsJam API license key.

game_id#

NOTE

You can pass in multiple of this parameter.

The id of the game that you want to recieve score changes for.

league#

NOTE

You can pass in multiple of this parameter.

The league you want to receive score changes for (e.g. NCAAB)

last_entry_id#

If this is set, it will get all events after the entry with this id, you can use this on reconnection events so you do not miss any updates. Note that this if you try and set a last_entry_id older than 30s ago, it will not use that and it will fallback to the last_entry_id that was at most 30s ago. The reason for this is to prevent abuse and cause our servers to go down.

Best Practices#

While our endpoint supports passing multiple leagues and game ids, we recommend making a separate connection for each league or game id that you are trying to subscribe to. This will help reduce and isolate issues on a game or league basis. For instance, if you pass [game_id1, game_id2], if game_id2 ends and you are reconnecting to the stream, you will get an error saying game_id2 is no longer active.

Example Request Python#

Requirements

import requests
from requests.exceptions import ChunkedEncodingError
import json
import sseclient # pip install sseclient-py
while True:
try:
r = requests.get(
"https://api-external.oddsjam.com/api/v2/stream/results",
params={
"key": "1234-5678-124",
"league": ["NCAAB"],
},
stream=True,
)
client = sseclient.SSEClient(r)
for event in client.events():
if event.event == "game-results":
data = json.loads(event.data)
print("results data", ":", data)
else:
print(event.event, ":", event.data)
except ChunkedEncodingError as ex:
print("Disconnected, attempting to reconnect...")
except Exception as e:
print("Error:", r.status_code, r.text)
break

Example Request Node.js#

const EventSource = require("eventsource"); // npm install eventsource
const url = "https://api-external.oddsjam.com/api/v2/stream/results";
const params = {
key: "1234-5678-124",
league: ["NCAAB"],
};
function connectToStream() {
// Construct the query string with repeated parameters
const queryString = new URLSearchParams();
queryString.append("key", params.key);
params.league.forEach((league) => queryString.append("league", league));
console.log(`${url}?${queryString.toString()}`);
const eventSource = new EventSource(`${url}?${queryString.toString()}`);
eventSource.onmessage = function (event) {
try {
const data = JSON.parse(event.data);
console.log("message data:", data);
} catch (e) {
console.log("Error parsing message data:", e);
}
};
eventSource.addEventListener("game-results", function (event) {
const data = JSON.parse(event.data);
console.log("results data:", data);
});
eventSource.onerror = function (event) {
console.error("EventSource failed:", event);
eventSource.close();
setTimeout(connectToStream, 1000); // Attempt to reconnect after 1 second
};
}
connectToStream();

Example Raw Response (from CURL)#

We send a connected event.

event: connected
data: OK

We send a ping from the server to the client every 5 seconds.

event: ping
data: 2023-02-22 16:30:08.952760

We send a game-results event.

event: game-results
id: 1718321101861-0
retry: 5000
data: {"data":{"game_id":"40548-32800-2024-06-13-15","is_live":true,"league":"MLB","player_results":[{"game_id":"40548-32800-2024-06-13-15","id":"016791443D5E","league":"MLB","player_id":"3C49F4B7013A","player_name":"Yandy Diaz","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"4B87C3A75BCB","league":"MLB","player_id":"26219D377197","player_name":"Christopher Morel","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"72859B93A5E1","league":"MLB","player_id":"6E6E734074FF","player_name":"Cody Bellinger","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":1,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":1,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"806078EAD487","league":"MLB","player_id":"B1178630A9C9","player_name":"Nico Hoerner","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"453616E11CA1","league":"MLB","player_id":"EE4FD49CE835","player_name":"Mike Tauchman","sport":"baseball","stat_at_bats":2,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":2,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"5FC3375CDE4C","league":"MLB","player_id":"5A596340C059","player_name":"Pete Crow-Armstrong","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"2DE00CD9F286","league":"MLB","player_id":"19F08A683CCD","player_name":"Patrick Wisdom","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"D3EDB11F05A1","league":"MLB","player_id":"249EECC994FE","player_name":"Yan Gomes","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"E6740F6D9D0C","league":"MLB","player_id":"A79EDA2441E9","player_name":"Seiya Suzuki","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"3F3A76A46011","league":"MLB","player_id":"4532C49C1A0F","player_name":"Jose Caballero","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"A54D7C18B845","league":"MLB","player_id":"C2AF1F6B8498","player_name":"Alex Jackson","sport":"baseball","stat_at_bats":0,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"5C0BEFC764A9","league":"MLB","player_id":"CABCC3C42356","player_name":"Isaac Paredes","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"442DD926B22D","league":"MLB","player_id":"77968DD00FBE","player_name":"Jonny DeLuca","sport":"baseball","stat_at_bats":0,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"13970F881E59","league":"MLB","player_id":"3A8716443137","player_name":"Taj Bradley","sport":"baseball","stat_batters_faced":10,"stat_batting_flyballs_allowed":1,"stat_batting_groundballs_allowed":4,"stat_blown_save_pitcher":0,"stat_complete_game":0,"stat_doubles_allowed":0,"stat_earned_runs":0,"stat_ground_into_double_play_allowed":0,"stat_hits_allowed":1,"stat_holding_pitcher":0,"stat_home_runs_allowed":0,"stat_innings_pitched":3,"stat_losing_pitcher":0,"stat_opponent_at_bats":10,"stat_pitch_count":39,"stat_pitching_balks":0,"stat_pitching_balls":13,"stat_pitching_hit_batsmen":0,"stat_pitching_intentional_walks":0,"stat_pitching_no_hitter":0,"stat_pitching_perfect_game":0,"stat_pitching_pickoffs":0,"stat_pitching_shutout":0,"stat_pitching_strikes":26,"stat_pitching_walks":0,"stat_pitching_wild_pitches":0,"stat_runs_allowed":0,"stat_sacrifice_flies_allowed":0,"stat_sacrifice_hits_allowed":0,"stat_save_pitcher":0,"stat_stolen_bases_allowed":0,"stat_strikeouts":4,"stat_triples_allowed":0,"stat_winning_pitcher":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"AE5FFDE308A8","league":"MLB","player_id":"6E05F2D1D28F","player_name":"Justin Steele","sport":"baseball","stat_batters_faced":7,"stat_batting_flyballs_allowed":0,"stat_batting_groundballs_allowed":4,"stat_blown_save_pitcher":0,"stat_complete_game":0,"stat_doubles_allowed":0,"stat_earned_runs":0,"stat_ground_into_double_play_allowed":0,"stat_hits_allowed":0,"stat_holding_pitcher":0,"stat_home_runs_allowed":0,"stat_innings_pitched":2.1,"stat_losing_pitcher":0,"stat_opponent_at_bats":7,"stat_pitch_count":32,"stat_pitching_balks":0,"stat_pitching_balls":10,"stat_pitching_hit_batsmen":0,"stat_pitching_intentional_walks":0,"stat_pitching_no_hitter":0,"stat_pitching_perfect_game":0,"stat_pitching_pickoffs":0,"stat_pitching_shutout":0,"stat_pitching_strikes":22,"stat_pitching_walks":0,"stat_pitching_wild_pitches":0,"stat_runs_allowed":0,"stat_sacrifice_flies_allowed":0,"stat_sacrifice_hits_allowed":0,"stat_save_pitcher":0,"stat_stolen_bases_allowed":0,"stat_strikeouts":3,"stat_triples_allowed":0,"stat_winning_pitcher":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"EBB32F3ECE4B","league":"MLB","player_id":"328C68E577E6","player_name":"Randy Arozarena","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"53FD27079E08","league":"MLB","player_id":"67C877519A5D","player_name":"Jose Siri","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"9E1035DD3C03","league":"MLB","player_id":"4C8060AE3A89","player_name":"Michael Busch","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"92EC2529E35A","league":"MLB","player_id":"4DD6693C6C83","player_name":"Brandon Lowe","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":1,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"},{"game_id":"40548-32800-2024-06-13-15","id":"25E8D53E3305","league":"MLB","player_id":"4CCDA44E1F86","player_name":"Amed Rosario","sport":"baseball","stat_at_bats":1,"stat_batting_ground_into_double_play":0,"stat_batting_hit_by_pitch":0,"stat_batting_intentional_walks":0,"stat_batting_picked_off":0,"stat_batting_plate_appearances":1,"stat_batting_sacrifice_flies":0,"stat_batting_sacrifice_hits":0,"stat_batting_strikeouts":0,"stat_batting_walks":0,"stat_caught_stealing":0,"stat_doubles":0,"stat_hits":0,"stat_home_runs":0,"stat_rbi":0,"stat_runs":0,"stat_starter":1,"stat_stolen_bases":0,"stat_total_bases":0,"stat_triples":0,"status":"live"}],"score":{"attendance":"0","away_starter":"Justin Steele","away_team":"Chicago Cubs","away_team_abb":"CHC","away_team_city":"Chicago","away_team_id":"5045D954DFF8","away_team_name":"Cubs","broadcast":"MARQ | BSUN | MLBN","capacity":null,"clock":"Bottom","current_balls":1,"current_batter_name":"Jonny DeLuca","current_down_and_distance":null,"current_outs":1,"current_pitcher_name":null,"current_possession":null,"current_strikes":0,"decision":null,"decision_method":null,"description":"Chicago Cubs vs Tampa Bay Rays","duration":null,"game_id":"40548-32800-2024-06-13-15","home_starter":"Taj Bradley","home_team":"Tampa Bay Rays","home_team_abb":"TB","home_team_city":"Tampa Bay","home_team_id":"FE07CF8C473A","home_team_name":"Rays","is_live":true,"last_play":null,"league":"MLB","period":"3","runner_on_first":null,"runner_on_second":null,"runner_on_third":null,"score_away_period_1":0,"score_away_period_2":0,"score_away_period_3":0,"score_away_total":0,"score_home_period_1":0,"score_home_period_2":0,"score_home_period_3":0,"score_home_total":0,"season_type":"Regular Season","season_week":null,"season_year":"2024","sport":"baseball","start_date":"2024-06-13T22:50:00+00:00","status":"Live","team_stats":{"away_stats":{"stat_at_bats":10,"stat_batting_strikeouts":4,"stat_batting_walks":0,"stat_double_plays":0,"stat_hits":1,"stat_rbi":0,"stat_runners_left_on_base":1,"stat_runs":0,"stat_total_bases":1,"stat_triple_plays":0},"home_stats":{"stat_at_bats":7,"stat_batting_strikeouts":3,"stat_batting_walks":0,"stat_double_plays":0,"stat_hits":0,"stat_rbi":0,"stat_runners_left_on_base":0,"stat_runs":0,"stat_total_bases":0,"stat_triple_plays":0}},"venue_location":"St. Petersburg, FL","venue_name":"Tropicana Field","weather":null,"weather_temp":null,"weather_temp_high":null},"sport":"baseball"},"entry_id":"1718321101861-0"}