You need a definitive list of sports, with stable IDs, slugs, and names, to drive navigation, filters, or lookups in your app. By the end of this guide, you’ll ship an integration that fetches every available sport from a single endpoint, parse it in code, and optionally enrich your UI with country flags and global search using the same API family.
What this API gives you
The SofaScore - Live API on Zyla API Hub exposes a simple read endpoint that returns all available sports as an array of objects, each with an id, name, and slug. This list is suitable for bootstrapping your sports taxonomy, driving dropdowns, or mapping sport slugs to routes. The same API also provides:
- A country flag endpoint (image bytes) for UI decoration or attribution.
- A cross-entity search endpoint for teams, clubs, and related entities by text query.
Because this runs on Zyla API Hub, you use one account and one API key under a subscription + quota model (not pay-per-call). The platform hosts more than 10,000 public APIs with consistent auth and billing. For your first API, you can start a 7-day trial or 50 requests (no Free Plan). Check the API page for current access options and pricing.
Getting started on Zyla API Hub
Open the SofaScore - Live API page and start the trial to get an API key:
- Go to Start 7-day trial on SofaScore - Live API.
- Click Subscribe or Start Free Trial when available, then copy your API key.
- Send requests with the header: Authorization: Bearer YOUR_API_KEY
You can manage your key and subscriptions directly from your Zyla API Hub account.
Endpoints you’ll use
This section documents the three endpoints relevant to “API to get all sports,” with their exact request URLs, methods, and parameters (only where specified). Do not add request bodies; these endpoints are simple GETs with query params as shown.
1) Get all sports
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports
- Description: Returns a list of all available sports.
- Parameters: none documented.
- Auth: Authorization: Bearer YOUR_API_KEY
cURL (official sample):
curl -s -X GET "https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports" \
-H "Authorization: Bearer YOUR_API_KEY"
Example JSON (official sample):
[
{
"id": 1,
"name": "Football",
"slug": "football"
},
{
"id": 5,
"name": "Tennis",
"slug": "tennis"
},
{
"id": 2,
"name": "Basketball",
"slug": "basketball"
},
{
"id": 64,
"name": "Baseball",
"slug": "baseball"
},
{
"id": 23,
"name": "Volleyball",
"slug": "volleyball"
},
{
"id": 63,
"name": "American football",
"slug": "american-football"
},
{
"id": 6,
"name": "Handball",
"slug": "handball"
},
{
"id": 20,
"name": "Table tennis",
"slug": "table-tennis"
},
{
"id": 4,
"name": "Ice hockey",
"slug": "ice-hockey"
},
{
"id": 22,
"name": "Darts",
"slug": "darts"
},
{
"id": 72,
"name": "E-sports",
"slug": "esports"
},
{
"id": 11,
"name": "Motorsport",
"slug": "motorsport"
},
{
"id": 65,
"name": "Cycling",
"slug": "cycling"
},
{
"id": 62,
"name": "Cricket",
"slug": "cricket"
},
{
"id": 76,
"name": "Mixed Martial Arts",
"slug": "mma"
},
{
"id": 12,
"name": "Rugby",
"slug": "rugby"
},
{
"id": 29,
"name": "Futsal",
"slug": "futsal"
},
{
"id": 31,
"name": "Badminton",
"slug": "badminton"
},
{
"id": 26,
"name": "Waterpolo",
"slug": "waterpolo"
},
{
"id": 19,
"name": "Snooker",
"slug": "snooker"
},
{
"id": 13,
"name": "Aussie rules",
"slug": "aussie-rules"
},
{
"id": 34,
"name": "Beach volley",
"slug": "beach-volley"
},
{
"id": 109,
"name": "Minifootball",
"slug": "minifootball"
},
{
"id": 7,
"name": "Floorball",
"slug": "floorball"
},
{
"id": 15,
"name": "Bandy",
"slug": "bandy"
},
{
"id": 110,
"name": "Padel",
"slug": "padel"
}
]
What to use:
- id: stable integer identifier. Use it as your primary key or mapping to your own taxonomy.
- name: display label for UIs.
- slug: lowercase, URL-friendly identifier (good for routes and query params).
Practical notes:
- Caching: This list is relatively static. Cache it in your app for hours or a day, depending on refresh needs. Bust cache on deploys or via a manual admin control.
- Localization: The response shows English names. If you need localization layers, map slugs to your own i18n strings.
- Ordering: If you need a specific order, sort by name or apply a custom weight map (e.g., prioritize Football, Basketball, Tennis).
2) Get country flag
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/31197/get-country-flag
- Description: Returns the country flag image bytes.
- Parameters (required): country_code (string). Example value: EN
- Auth: Authorization: Bearer YOUR_API_KEY
cURL:
Example response:
iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAMAAAAL34HQAAAABGdBTUEAALGPC/xhBQ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jUMlJWRl4IRF60R+3biN5wxmeKr4WNDH…
Usage notes:
- Response is raw image bytes. Store to disk, cache via CDN, or convert to base64 in memory for immediate rendering in a web client.
- country_code is a string (example: EN). Validate your inputs to avoid unnecessary retries.
3) Search all entities
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/25082/search-all-entities
- Description: Search all SofaScore entities by query string.
- Parameters (required): q (string). Example value: real madrid
- Auth: Authorization: Bearer YOUR_API_KEY
cURL:
Example response:
[{"entity":{"id":2829,"name":"Real Madrid","slug":"real-madrid","imagePath":"https:\/\/img.sofascore.com\/api\/v1\/team\/2829\/image","proxyImagePath":"https:\/\/betting.asdasddsgdfgfdsgfj.website\/sofascore\/image-proxy?imagePath=https:\/\/img.sofascore.com\/api\/v1\/team\/2829\/image","fullName":null,"shortName":null,"nameCode":"RMA","gender":"M","country":{"name":"Spain","slug":"spain","alpha2":"ES","alpha3":null,"imagePath":"https:\/\/img.sofascore.com\/api\/v1\/country\/ES\/flag","proxyImagePath":"https:\/\/betting.asdasddsgdfgfdsgfj.website\/sofascore\/image-proxy?imagePath=https:\/\/img.sofascore.com\/api\/v1\/country\/ES\/flag"},"foundationDateTimestamp":null,"manager":[],"ranking":null,"national":false,"venue":[],"sport":{"id":1,"name":"Football","slug":"football"}},"score":4293164.5,"type":"team"},{"entity":{"id":2816,"name":"Real Betis","slug":"real-betis","imagePath":"https:\/\/img.sofascore.com\/api\/v1\/team\/2816\/image","proxyImagePath":"https:\/\/betting.asdasddsgdfgfdsgfj.website\/sofascore\/image-proxy?imagePath=https:\/\/img.sofascore.com\/api\/v1\/team\/2816\/image","fullName":null,"shortName":null,"nameCode":"BET","gender":"M","country":{"name":"Spain","slug":"spain","alpha2":null,"alpha3":null,"imagePath":"https:\/\/img.sofascore.com\/api\/v1\/country\/ES\/flag","proxyImagePath":"https:\/\/betting.asdasddsgdfgfdsgfj.website\/sofascore\/image-proxy?imagePath=https:\/\/img.sofascore.com\/api\/v1\/country\/ES\/flag"},"foundationDateTimestamp":null,"manager":[],"ranking":null,"national":false,"venue":[],"sport":{"id":1,"name":"Football","slug":"football"}},"score":...}]
Usage notes:
- Use q to implement global search bars for teams and entities. Debounce client-side to reduce calls.
- The response structure includes entity metadata such as id, name, slug, country, and sport. Cache popular queries.
Copy-paste code: load the sports list in Python
The example below calls Get all sports, checks HTTP status, parses JSON into a list of dicts, and builds two lookup structures you’ll actually use: id-to-name and slug-to-id. Insert your API key where indicated.
import os
import sys
import json
import urllib.request
API_URL = "https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports"
API_KEY = os.environ.get("ZYLALABS_API_KEY", "YOUR_API_KEY")
req = urllib.request.Request(API_URL, method="GET")
req.add_header("Authorization", f"Bearer {API_KEY}")
try:
with urllib.request.urlopen(req, timeout=10) as resp:
if resp.status != 200:
sys.stderr.write(f"HTTP {resp.status}\\n")
sys.exit(1)
data = json.loads(resp.read().decode("utf-8"))
except Exception as e:
sys.stderr.write(f"Request failed: {e}\\n")
sys.exit(1)
# Build lookups useful in real apps:
id_to_name = {item["id"]: item["name"] for item in data}
slug_to_id = {item["slug"]: item["id"] for item in data}
# Example usage: route building and validation
def sport_exists(slug):
return slug in slug_to_id
# Print a quick summary and a route example
print(f"Loaded {len(data)} sports")
for s in data[:5]:
print(f"- {s['name']} (id={s['id']}, slug={s['slug']})")
example_slug = "football"
if sport_exists(example_slug):
sport_id = slug_to_id[example_slug]
print(f"/sports/{example_slug} maps to sport_id={sport_id}")
else:
print(f"{example_slug} not present")
Implementation tips:
- Timeouts: set reasonable timeouts (e.g., 5–10s) to avoid hanging requests.
- Retries: for transient errors, retry with exponential backoff. Avoid unbounded loops.
- Caching: file cache or in-memory TTL cache is often enough for this static list.
Practical use cases you can ship this week
- Navigation bootstrap: Fetch sports once on server start and generate /sports/{slug} routes and sitemaps.
- Filter UIs: Populate sport selectors in dashboards or mobile apps using name and slug.
- Search + details: Combine Get all sports with Search all entities to build a single search box that returns teams scoped by sport.
- Branding and flags: When you display teams or competitions returned by search, decorate with country flags using Get country flag.
- Server-side rendering: Fetch the sports list at build time (or on-demand with cache) to speed up page loads.
End-to-end: from list to UI polish
1) Load all sports
Call the Get all sports endpoint once and store the response. Use slug for URL-safe links and id for database joins or analytics tagging.
2) Add quick search
Wire an input to the Search all entities endpoint. Debounce at 250–500 ms and cache the last few queries. Render name, country, and sport name where available.
3) Decorate with flags
When an entity includes a country, call Get country flag with the required country_code. Cache image bytes or store them on first request.
MCP: call this API from an AI agent
Every API on Zyla can also be called via the MCP-compatible endpoint, which works with Claude Code, Cursor, Windsurf, and other MCP clients. Point your agent or tool to:
- Endpoint: https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY
This allows your agent to invoke the same SofaScore - Live API operations with your Zyla key in environments that support the MCP protocol. Refer to MCP for details on client setup. Keep the same Authorization approach for direct HTTP calls; within MCP, provide your Zyla key as required by your MCP client’s configuration.
Operational guidance
- Authentication: Always send Authorization: Bearer YOUR_API_KEY.
- Quotas and billing: Subscription + quota model (not pay-per-call). For your first API, you can start with a 7-day trial or 50 requests. No Free Plan. Check the listing for current access options.
- Error handling: Handle non-200 statuses gracefully. Do not retry on 4xx except 429 with backoff if applicable.
- Observability: Log endpoint, status, and latency. For caching, log cache hits vs misses to keep call volume predictable.
Reference: All three endpoints at a glance
- Get all sports
- GET https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports
- Params: none documented
- Returns: array of { id, name, slug }
- Get country flag
- GET https://zylalabs.com/api/12787/sofascore-live-api/31197/get-country-flag
- Params: country_code (string, required), e.g., EN
- Returns: image bytes
- Search all entities
- GET https://zylalabs.com/api/12787/sofascore-live-api/25082/search-all-entities
- Params: q (string, required), e.g., real madrid
- Returns: list of matching entities with metadata, including sport
FAQ
How do I authenticate requests?
Add the header Authorization: Bearer YOUR_API_KEY to each request.
Is there a free plan?
No Free Plan. For your first API, you can start a 7-day trial or 50 requests. See the API page for current access options and pricing.
How often should I refresh the sports list?
The sports list is relatively stable. Cache it and refresh on a schedule that fits your app (e.g., daily) or on deploy. Invalidate manually if you need immediate updates.
Can I get images (like flags) directly from the API?
Yes. Use Get country flag with the required country_code to receive raw image bytes. Cache or CDN these responses for performance.
Can I search for teams or clubs?
Yes. Use Search all entities with q to find teams and other entities. Parse the returned entity objects to render names, slugs, and country information.
Ready to ship? Create your account on Zyla API Hub, then start your trial and plug in the endpoints above. Start here: Start 7-day trial on SofaScore - Live API.