You need to ship a sports integration that can: list all supported sports, search teams/leagues/players by name, and render country flags without hunting down image assets. By the end of this guide you’ll call the SofaScore - Live API on Zyla API Hub to do exactly that, with copy‑pasteable requests you can drop into production this week.
What this API does and when to use it
The SofaScore - Live API on Zyla API Hub provides three core capabilities you can wire into scoreboards, discovery flows, and UI components:
- Get all sports: enumerate supported sports (id, name, slug) for app bootstrapping and filters.
- Search all entities: query SofaScore entities (e.g., teams) by free text to power search bars and autocomplete.
- Get country flag: fetch raw image bytes for a country flag, useful when showing team or player nationality.
It’s delivered through a single Zyla subscription and key, with a consistent Authorization header across endpoints. Zyla hosts more than 10,000 public APIs behind one account and one API key, so you can add more sports and gaming data later without reworking auth flows. Explore the catalog at zylalabs.com.
Getting started on Zyla API Hub
Open the SofaScore - Live API page on Zyla API Hub and subscribe. The first API on your account includes a 7‑day trial or 50 requests, and billing uses a subscription + quota model (not pay‑per‑call). For current access options and pricing, check the API page directly. After subscribing you’ll receive an API key.
All requests below include this header:
- Authorization: Bearer YOUR_API_KEY
Endpoints you can wire up today
1) Get all sports
Use this endpoint to populate a static sports list for navigation, filters, or onboarding. It returns an array of sports with id, name, and slug.
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-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"
JSON response (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 you’ll actually use:
- id: stable numeric identifier per sport (store in DB; use for filters).
- name: human‑readable label (display in UI).
- slug: URL‑friendly identifier (use for routes or canonical keys).
Python example (requests):
import requests
API_KEY = "YOUR_API_KEY"
url = "https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports"
headers = {"Authorization": f"Bearer {API_KEY}"}
resp = requests.get(url, headers=headers, timeout=10)
resp.raise_for_status()
sports = resp.json()
# Build a mapping and print a sorted menu
slug_by_id = {s["id"]: s["slug"] for s in sports}
menu = [f'{s["id"]}: {s["name"]} ({s["slug"]})' for s in sports]
print("\n".join(sorted(menu, key=lambda x: x.lower())))
# Example: pick the football sport id
football_id = next((s["id"] for s in sports if s["slug"] == "football"), None)
print("football_id =", football_id)
2) Search all entities
Use this to search for SofaScore entities by a free‑text query string (e.g., team names). This is ideal for autocomplete and “jump to team” features.
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/25082/search-all-entities
- Parameters:
- q (string, required): the search term. Example: real madrid
- Auth: Authorization: Bearer YOUR_API_KEY
cURL:
Example response (excerpt as provided by the hub):
[{"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":…
Notes for implementers:
- Read entity.id, entity.name, entity.slug, and type to categorize results (e.g., team vs. other types).
- The response includes image URLs you can proxy if needed; use as-is according to your UI.
- For fast UIs, debounce the query and cache recent results keyed by q.
3) Get country flag
Fetch country flag image bytes. Useful to show a player’s or team’s country flag without maintaining your own asset store.
- Method: GET
- URL: https://zylalabs.com/api/12787/sofascore-live-api/31197/get-country-flag
- Parameters:
- country_code (string, required): EN
- Auth: Authorization: Bearer YOUR_API_KEY
cURL:
Example response (image bytes excerpt):
iVBORw0KGgoAAAANSUhEUgAAAJYAAAC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X16GqaGhfccCiOoaoq2Vc2/WwVHGxwNBDjUMlJWRl4IRF60R+3biN5wxmeKr4WNDH…
Implementation tips:
- The response is the image data; store or stream it to your frontend as needed.
- Cache flags in your CDN or object store to avoid repeated downloads.
Putting it together: common integration patterns
- Bootstrap filters: call Get all sports during app init, store id/name/slug, and expose the list in a dropdown.
- Search bar: on user input, call Search all entities with q. Debounce by 250–400 ms, cache by query to reduce calls.
- National flags: when displaying a team or player card, call Get country flag once per code and cache the result; reuse from cache across pages.
Authentication and request hygiene
- Send Authorization: Bearer YOUR_API_KEY on every request.
- Treat the sports list as relatively static; refresh it occasionally in the background and store locally.
- Build basic error handling paths: network timeouts, non‑200 statuses, and empty arrays from search.
Call this API from AI agents via MCP
If you use AI coding agents (e.g., MCP‑compatible IDEs and tools), you can call the same endpoints through the Zyla MCP bridge. Point your client to the MCP endpoint and supply your Zyla API key in the query string. For details, see MCP. The agent can then make the same GET requests shown above, using the hub URLs and the Authorization header.
Operational notes that save time
- Idempotence: the documented endpoints are GETs; they’re safe to retry on transient failures.
- Client caching: cache Get all sports in memory and persist to a lightweight data store; refresh at app startup.
- Binary data handling: the flag endpoint returns image bytes. When proxying to browsers, set headers appropriate to your environment so the client can render or download as intended.
- Usage planning: Zyla APIs use subscription + quota. The first API on your account includes a 7‑day trial or 50 requests; verify your current quota on the API page before load testing.
Deep dive examples
Search: shaping results for a suggestion list
After calling the search endpoint, extract a lightweight projection per result:
- id: numeric entity id
- label: entity.name
- type: type (e.g., team) to badge results
- sport: entity.sport.slug for scoping
- country: entity.country.alpha2 when present; if you need a flag, call Get country flag with the required country_code parameter
This projection is compact and keeps your UI fast.
Flags: serving to the browser
When your backend receives the image bytes from Get country flag, you can:
- Store the bytes as a PNG in object storage and CDN‑cache by a normalized key (e.g., flag-EN.png).
- Return a data URI to your frontend if you want a zero‑roundtrip render; note the size implications for HTML payloads.
Full reference
Get all sports
- GET https://zylalabs.com/api/12787/sofascore-live-api/25080/get-all-sports
- Params: none documented
- Auth: Authorization: Bearer YOUR_API_KEY
Search all entities
- GET https://zylalabs.com/api/12787/sofascore-live-api/25082/search-all-entities
- Params:
- q (string, required): the search query
- Auth: Authorization: Bearer YOUR_API_KEY
Get country flag
- GET https://zylalabs.com/api/12787/sofascore-live-api/31197/get-country-flag
- Params:
- country_code (string, required): EN
- Auth: Authorization: Bearer YOUR_API_KEY
FAQ
How do I authenticate requests?
Include the header: Authorization: Bearer YOUR_API_KEY on every call to the hub URLs.
Is there a free plan?
The model is subscription + quota. For your first API on Zyla, you get a 7‑day trial or 50 requests. Check the API page for current access options and pricing.
Can I paginate results from search?
Pagination details are not documented here. Use the provided search endpoint and handle the returned array as is.
What format does the flag endpoint return?
It returns image bytes. The sample shows a PNG‑like byte stream. Store or serve as appropriate for your app.
Which fields should I persist from the sports list?
Persist id, name, and slug. id is a good stable key; name and slug are used in UI and routing.
Ready to wire this into your app? Create a free account on Zyla, get your key, and start building with the SofaScore - Live API. Start here: Start 7-day trial on SofaScore - Live API. You can always explore more sports and gaming APIs later at zylalabs.com.