SoccersAPIDocsv2.2
Docs/Guides

Code Examples

Each example requests Premier League fixture 2589310 from season 21033 (2026/27) and includes events and team statistics. Examples use the api_key query parameter and read the key from SOCCERSAPI_API_KEY. Set that environment variable on your server before running them. Never put a production key in source control or browser-delivered code. Redact api_key in request logs and never share URLs containing a real key. The same key also works with the Bearer header; see Authentication methods.

cURLNode.jsPythonPHPJavaC#GoRuby

cURL

curl --get 'https://api.soccersapi.com/v2.2/fixtures/' \
  --data-urlencode "api_key=${SOCCERSAPI_API_KEY:?Set SOCCERSAPI_API_KEY}" \
  --data-urlencode 't=info' \
  --data-urlencode 'id=2589310' \
  --data-urlencode 'include=events,stats'

Node.js

const apiKey = process.env.SOCCERSAPI_API_KEY;
if (!apiKey) throw new Error('Missing SOCCERSAPI_API_KEY');
const url = new URL('https://api.soccersapi.com/v2.2/fixtures/');
url.search = new URLSearchParams({
  api_key: apiKey,
  t: 'info',
  id: '2589310',
  include: 'events,stats',
});

const response = await fetch(url, {
  signal: AbortSignal.timeout(15000),
});
if (!response.ok) throw new Error(`SoccersAPI ${response.status}`);
const body = await response.json();
console.log(body.data);

Python

import os
import requests

response = requests.get(
    "https://api.soccersapi.com/v2.2/fixtures/",
    params={
        "api_key": os.environ["SOCCERSAPI_API_KEY"],
        "t": "info",
        "id": 2589310,
        "include": "events,stats",
    },
    timeout=15,
)
response.raise_for_status()
print(response.json()["data"])

PHP

<?php
$apiKey = getenv('SOCCERSAPI_API_KEY');
if (!$apiKey) throw new RuntimeException('Missing SOCCERSAPI_API_KEY');
$query = http_build_query([
    'api_key' => $apiKey,
    't' => 'info',
    'id' => '2589310',
    'include' => 'events,stats',
]);

$curl = curl_init("https://api.soccersapi.com/v2.2/fixtures/?$query");
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status !== 200) throw new RuntimeException("SoccersAPI $status");
print_r(json_decode($body, true)['data']);

Java

import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.nio.charset.StandardCharsets;

public class Example {
    public static void main(String[] args) throws Exception {
        var apiKey = System.getenv("SOCCERSAPI_API_KEY");
        if (apiKey == null || apiKey.isBlank()) {
            throw new IllegalStateException("Missing SOCCERSAPI_API_KEY");
        }
        var url = "https://api.soccersapi.com/v2.2/fixtures/?api_key="
            + URLEncoder.encode(apiKey, StandardCharsets.UTF_8)
            + "&t=info&id=2589310&include=events%2Cstats";
        var request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(15))
            .GET()
            .build();
        var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(15)).build();
        var response = client.send(request, BodyHandlers.ofString());
        if (response.statusCode() != 200) throw new IOException("SoccersAPI " + response.statusCode());
        System.out.println(response.body());
    }
}

C#

using System;
using System.Net.Http;

var apiKey = Environment.GetEnvironmentVariable("SOCCERSAPI_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) throw new InvalidOperationException("Missing SOCCERSAPI_API_KEY");
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(15) };
var url = "https://api.soccersapi.com/v2.2/fixtures/?api_key="
    + Uri.EscapeDataString(apiKey)
    + "&t=info&id=2589310&include=events%2Cstats";
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Go

package main

import (
    "io"
    "log"
    "net/http"
    "net/url"
    "os"
    "time"
)

func main() {
    apiKey := os.Getenv("SOCCERSAPI_API_KEY")
    if apiKey == "" { log.Fatal("Missing SOCCERSAPI_API_KEY") }
    params := url.Values{
        "api_key": {apiKey},
        "t": {"info"},
        "id": {"2589310"},
        "include": {"events,stats"},
    }
    request, err := http.NewRequest("GET", "https://api.soccersapi.com/v2.2/fixtures/?" + params.Encode(), nil)
    if err != nil { log.Fatal("Could not create request") }
    client := &http.Client{Timeout: 15 * time.Second}
    response, err := client.Do(request)
    if err != nil { log.Fatal("SoccersAPI request failed") }
    defer response.Body.Close()
    if response.StatusCode != http.StatusOK { log.Fatalf("SoccersAPI %s", response.Status) }
    if _, err := io.Copy(os.Stdout, response.Body); err != nil { log.Fatal("Could not read response") }
}

Ruby

require 'net/http'
require 'uri'
require 'json'

api_key = ENV.fetch('SOCCERSAPI_API_KEY')
uri = URI('https://api.soccersapi.com/v2.2/fixtures/')
uri.query = URI.encode_www_form(
  api_key: api_key,
  t: 'info',
  id: 2_589_310,
  include: 'events,stats'
)

request = Net::HTTP::Get.new(uri)
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 15, read_timeout: 15) do |http|
  http.request(request)
end
raise "SoccersAPI #{response.code}" unless response.is_a?(Net::HTTPSuccess)
puts JSON.parse(response.body).fetch('data')

The interactive reference generates additional clients from the same OpenAPI operation. Always remove credentials before pasting a generated request into a ticket, chat or public repository.

Read in the reference