Fetching Teams
Overview
The Sports Game Odds API provides the ability to fetch a list of teams or a specific team’s details.
You can use a sportID or leagueID to get a list of associated teams and their details. You can also pass a teamID to just get a single team’s details. Note that when specifying a teamID, it will still return as an array, just with a single object in it.
Fetching by Team
Let’s take the following example, where we want to fetch the details of a specific NBA team:
fetch('https://api.sportsgameodds.com/v1/teams?teamID=LOS_ANGELES_LAKERS_NBA', {
headers: {
'X-Api-Key': 'YOUR_TOKEN'
}
})import requests
response = requests.get(
'https://api.sportsgameodds.com/v1/teams?teamID=LOS_ANGELES_LAKERS_NBA',
headers={'X-Api-Key': 'YOUR_TOKEN'}
)
print(response.json())require 'net/http'
require 'json'
uri = URI('https://api.sportsgameodds.com/v1/teams?teamID=LOS_ANGELES_LAKERS_NBA')
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = 'YOUR_TOKEN'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts JSON.parse(response.body)$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sportsgameodds.com/v1/teams?teamID=LOS_ANGELES_LAKERS_NBA');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: YOUR_TOKEN'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api.sportsgameodds.com/v1/teams?teamID=LOS_ANGELES_LAKERS_NBA");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("X-Api-Key", "YOUR_TOKEN");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
conn.disconnect();
JSONObject data = new JSONObject(content.toString());
System.out.println(data.toString(2));
} catch (Exception e) {
e.printStackTrace();
}
}
}This will return a response that looks something like this:
{
"success": true,
"data": [
{
"sportID": "BASKETBALL",
"names": {
"short": "LAL",
"medium": "Lakers",
"long": "Los Angeles Lakers"
},
"leagueID": "NBA",
"teamID": "LOS_ANGELES_LAKERS_NBA"
}
]
}Fetching by league
If you wanted to fetch a list of all the teams in the NBA, your request would look something like this:
fetch('https://api.sportsgameodds.com/v1/teams?leagueID=NBA', {
headers: {
'X-Api-Key': 'YOUR_TOKEN'
}
})import requests
response = requests.get(
'https://api.sportsgameodds.com/v1/teams?leagueID=NBA',
headers={'X-Api-Key': 'YOUR_TOKEN'}
)
print(response.json())require 'net/http'
require 'json'
uri = URI('https://api.sportsgameodds.com/v1/teams?leagueID=NBA')
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = 'YOUR_TOKEN'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts JSON.parse(response.body)$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sportsgameodds.com/v1/teams?leagueID=NBA');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: YOUR_TOKEN'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api.sportsgameodds.com/v1/teams?leagueID=NBA");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("X-Api-Key", "YOUR_TOKEN");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
conn.disconnect();
JSONObject data = new JSONObject(content.toString());
System.out.println(data.toString(2));
} catch (Exception e) {
e.printStackTrace();
}
}
}This will return a response that looks something like this:
{
"nextCursor": "MILWAUKEE_BUCKS_NBA",
"success": true,
"data": [
{
"sportID": "BASKETBALL",
"names": {
"short": "LAL",
"medium": "Lakers",
"long": "Los Angeles Lakers"
},
"leagueID": "NBA",
"teamID": "LAKERS_NBA",
"colors": {
"secondary": "#FFFFFF",
"primaryContrast": "#000000",
"secondaryContrast": "#552583",
"primary": "#552583"
}
},
{
"sportID": "BASKETBALL",
"names": {
"short": "BOS",
"medium": "Celtics",
"long": "Boston Celtics"
},
"leagueID": "NBA",
"teamID": "CELTICS_NBA",
"colors": {
"secondary": "#FFFFFF",
"primaryContrast": "#000000",
"secondaryContrast": "#007A33",
"primary": "#007A33"
}
},
// ...
// Up to 30 objects may be returned in this object. If there are more available
// then you'll see a nextCursor property you can use to fetch the next
// page of related objects.
]
}Fetching by sport
If you wanted to fetch a list of all basketball teams across all of our supported leagues, your request would look something like this:
fetch('https://api.sportsgameodds.com/v1/teams?leagueID=NBA', {
headers: {
'X-Api-Key': 'YOUR_TOKEN'
}
})import requests
response = requests.get(
'https://api.sportsgameodds.com/v1/teams?sportID=BASKETBALL',
headers={'X-Api-Key': 'YOUR_TOKEN'}
)
print(response.json())require 'net/http'
require 'json'
uri = URI('https://api.sportsgameodds.com/v1/teams?sportID=BASKETBALL')
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = 'YOUR_TOKEN'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts JSON.parse(response.body)$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sportsgameodds.com/v1/teams?sportID=BASKETBALL');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: YOUR_TOKEN'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api.sportsgameodds.com/v1/teams?sportID=BASKETBALL");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("X-Api-Key", "YOUR_TOKEN");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
conn.disconnect();
JSONObject data = new JSONObject(content.toString());
System.out.println(data.toString(2));
} catch (Exception e) {
e.printStackTrace();
}
}
}This will return a response that looks something like this:
{
"nextCursor": "BELMONT_NCAAB",
"success": true,
"data": [
{
"sportID": "BASKETBALL",
"names": {
"short": "LAL",
"medium": "Lakers",
"long": "Los Angeles Lakers"
},
"leagueID": "NBA",
"teamID": "LAKERS_NBA"
},
{
"sportID": "BASKETBALL",
"names": {
"short": "BOS",
"medium": "Celtics",
"long": "Boston Celtics"
},
"leagueID": "NBA",
"teamID": "CELTICS_NBA"
},
{
"sportID": "BASKETBALL",
"names": {
"short": "GSW",
"medium": "Warriors",
"long": "Golden State Warriors"
},
"leagueID": "NBA",
"teamID": "WARRIORS_NBA"
},
// ...
// Up to 30 objects may be returned in this object. If there are more available
// then you'll see a nextCursor property you can use to fetch the next
// page of related objects.
]
}