This is a generated Go SDK for the SportDevs API. The SDK provides sport-specific clients for compile-time safety and type checking.
- Installation
- Quick Start
- Architecture
- Available Sports
- Usage Examples
- API Reference
- Error Handling
- Best Practices
This SDK is a complete Go module with proper dependency management. You can integrate it in several ways:
# In your main project repository
git submodule add <your-sdk-repo-url> pkg/sportdevs-sdk
# Or copy the SDK directory into your project structure
# In your go.mod file:
replace sportdevs-sdk => ./pkg/sportdevs-sdk# Copy the generated .go files to your project
mkdir internal/sportdevs
cp sportdevs-sdk/*.go internal/sportdevs/
# Import: "your-project/internal/sportdevs"# For local development/testing
cd sportdevs-sdk
go mod tidy # Already done during generation
# In your main project go.mod:
replace sportdevs-sdk => ../path/to/sportdevs-sdk# When published to a repository
go get your-org/sportdevs-sdk
# Import: "your-org/sportdevs-sdk"Here's a simple example to get you started:
package main
import (
"context"
"fmt"
"log"
"sportdevs-sdk" // or "your-project/internal/sportdevs" for direct integration
)
func main() {
// Create a american-football client
client, err := sportdevs.NewAmericanFootballClient("your-api-key")
if err != nil {
log.Fatal(err)
}
// Make an API call
ctx := context.Background()
map[string]interface{}, err := client.GetAggNewsMatches(ctx, "", 0, 0, "") if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d results\n", len(map[string]interface{}))}The SDK is organized into six main files:
Contains the base Client struct that handles:
- HTTP communication with the SportDevs API
- Authentication via API key
- Request/response serialization
- Base URL construction
Provides type-safe clients for each sport:
AmericanFootballClientfor american-footballAussieRulesClientfor aussie-rulesBadmintonClientfor badmintonBandyClientfor bandyBaseballClientfor baseballBasketballClientfor basketballBeachVolleyballClientfor beach-volleyballCricketClientfor cricketDartsClientfor dartsEsportsClientfor esportsFloorballClientfor floorballFootballClientfor footballFutsalClientfor futsalHandballClientfor handballHockeyClientfor hockeyRugbyClientfor rugbySnookerClientfor snookerTableTennisClientfor table-tennisTennisClientfor tennisVolleyballClientfor volleyballWaterpoloClientfor waterpolo
Each sport client embeds the base Client and provides compile-time sport validation.
Contains all the generated API methods organized by sport client. Each method:
- Takes a
context.Contextas the first parameter - Accepts typed parameters for the API call
- Returns typed responses or errors
Contains Go structs representing API response schemas:
- Generated from OpenAPI schemas
- Properly tagged for JSON marshaling/unmarshaling
- Type-safe field access
Defines the module and its dependencies (standard library only).
Complete usage guide and API reference for the SDK.
This SDK supports the following sports:
- AmericanFootball (
american-football) -NewAmericanFootballClient(apiKey) - AussieRules (
aussie-rules) -NewAussieRulesClient(apiKey) - Badminton (
badminton) -NewBadmintonClient(apiKey) - Bandy (
bandy) -NewBandyClient(apiKey) - Baseball (
baseball) -NewBaseballClient(apiKey) - Basketball (
basketball) -NewBasketballClient(apiKey) - BeachVolleyball (
beach-volleyball) -NewBeachVolleyballClient(apiKey) - Cricket (
cricket) -NewCricketClient(apiKey) - Darts (
darts) -NewDartsClient(apiKey) - Esports (
esports) -NewEsportsClient(apiKey) - Floorball (
floorball) -NewFloorballClient(apiKey) - Football (
football) -NewFootballClient(apiKey) - Futsal (
futsal) -NewFutsalClient(apiKey) - Handball (
handball) -NewHandballClient(apiKey) - Hockey (
hockey) -NewHockeyClient(apiKey) - Rugby (
rugby) -NewRugbyClient(apiKey) - Snooker (
snooker) -NewSnookerClient(apiKey) - TableTennis (
table-tennis) -NewTableTennisClient(apiKey) - Tennis (
tennis) -NewTennisClient(apiKey) - Volleyball (
volleyball) -NewVolleyballClient(apiKey) - Waterpolo (
waterpolo) -NewWaterpoloClient(apiKey)
// AmericanFootball client
americanfootballClient, err := sportdevs.NewAmericanFootballClient("your-api-key")
// AussieRules client
aussierulesClient, err := sportdevs.NewAussieRulesClient("your-api-key")
// Badminton client
badmintonClient, err := sportdevs.NewBadmintonClient("your-api-key")ctx := context.Background()
// Get americanfootball aggnewsmatches
map[string]interface{}, err := americanfootballClient.GetAggNewsMatches(ctx, "", 0, 0, "")
if err != nil {
return err
}
// Get aussierules aggnewsmatches
map[string]interface{}, err := aussierulesClient.GetAggNewsMatches(ctx, "", 0, 0, "")
if err != nil {
return err
}
// Get badminton aggnewsmatches
map[string]interface{}, err := badmintonClient.GetAggNewsMatches(ctx, "", 0, 0, "")
if err != nil {
return err
}The SportDevs API uses PostgREST-style query operators. You may need to format parameters with operators:
// Exact match
result, err := client.GetMatches(ctx, "eq.123", 0, 10, "en")
// Greater than
result, err := client.GetMatches(ctx, "gt.100", 0, 10, "en")
// Like operation
result, err := client.GetTeams(ctx, "like.*United*", "", 0, 10, "en")
// In operation
result, err := client.GetPlayers(ctx, "in.(1,2,3)", "", 0, 10, "en")// Create a context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// API call will respect the timeout
result, err := client.GetMatches(ctx, "", 0, 10, "en")Most API methods accept these common parameters:
ctx context.Context- Request context for cancellation and timeoutsoffset int- Pagination offset (0-based)limit int- Maximum number of results to returnlang string- Language code (e.g., "en", "es", "fr")
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 47 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 45 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 31 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 25 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 49 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 58 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 28 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 48 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 40 more methods
GetAggNewsMatches()- Agg News MatchesGetClasses()- ClassesGetCountries()- CountriesGetCupBracket()- Cup BracketGetLeagues()- Leagues- ... and 42 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 34 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 82 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 48 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 55 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 56 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 54 more methods
GetAggNewsMatches()- Agg News MatchesGetClasses()- ClassesGetCountries()- CountriesGetCupBracket()- Cup BracketGetLeagues()- Leagues- ... and 30 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 38 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 45 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCoaches()- Coaches- ... and 46 more methods
GetAggNewsMatches()- Agg News MatchesGetArenas()- ArenasGetArenasByCountry()- Arenas By CountryGetClasses()- ClassesGetCountries()- Countries- ... and 40 more methods
Most methods return one of:
[]map[string]interface{}- For list endpointsmap[string]interface{}- For single resource endpoints- Typed structs (when available in models.go)
The SDK provides detailed error information:
result, err := client.GetMatches(ctx, "", 0, 10, "en")
if err != nil {
// Handle different types of errors
switch {
case strings.Contains(err.Error(), "context deadline exceeded"):
// Timeout error
fmt.Println("Request timed out")
case strings.Contains(err.Error(), "401"):
// Authentication error
fmt.Println("Invalid API key")
case strings.Contains(err.Error(), "404"):
// Not found
fmt.Println("Resource not found")
default:
// Other errors
fmt.Printf("API error: %v\n", err)
}
}// Good: Type-safe and clear intent
americanfootballClient, _ := sportdevs.NewAmericanFootballClient(apiKey)
// Avoid: Using wrong sport client for your data// Good: Proper context usage
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result, err := client.GetMatches(ctx, "", 0, 10, "en")// Good: Paginate through large result sets
const pageSize = 100
offset := 0
for {
map[string]interface{}, err := client.GetAggNewsMatches(ctx, "", offset, pageSize, "") if err != nil {
return err
}
if len(map[string]interface{}) == 0 {
break // No more results
}
// Process map[string]interface{}
for _, item := range map[string]interface{} {
// Process each item
}
offset += pageSize
}// Good: Proper PostgREST operators
result, err := client.GetTeams(ctx, "eq.123", "", 0, 10, "en") // Exact match
result, err := client.GetTeams(ctx, "like.*Arsenal*", "", 0, 10, "en") // Pattern match
result, err := client.GetTeams(ctx, "in.(1,2,3)", "", 0, 10, "en") // In list// Good: Create once, reuse multiple times
client, err := sportdevs.NewAmericanFootballClient(apiKey)
if err != nil {
return err
}
// Reuse for multiple calls
map[string]interface{}, _ := client.GetAggNewsMatches(ctx, "", 0, 0, "")
map[string]interface{}, _ := client.GetArenas(ctx, "", "", 0, 0, "")
map[string]interface{}, _ := client.GetArenasByCountry(ctx, "", 0, 0, "")The SDK is a self-contained Go module with the following characteristics:
- Module name: Configurable (defaults to
sportdevs-sdk) - Go version: 1.19+
- Dependencies: Standard library only
- Auto-generated:
go.modandgo.sumare managed automatically during SDK generation
The SDK automatically constructs the base URL using the pattern:
https://{sport}.sportdevs.com
The default HTTP client timeout is 30 seconds. You can customize this by modifying the client after creation:
client, _ := sportdevs.NewAmericanFootballClient(apiKey)
client.Client.Timeout = 60 * time.Second // 60 secondsIf you need to use a custom HTTP client (for proxies, custom certificates, etc.), you can replace the default client:
client, _ := sportdevs.NewAmericanFootballClient(apiKey)
client.Client = &http.Client{
Timeout: 45 * time.Second,
Transport: customTransport,
}-
"API key cannot be empty"
- Ensure you're passing a valid API key when creating the client
-
"context deadline exceeded"
- The request timed out. Consider increasing the timeout or checking network connectivity
-
"401 Unauthorized"
- Your API key is invalid or expired
-
"404 Not Found"
- The endpoint or resource doesn't exist for the specified sport
-
Empty results
- Check your query parameters and ensure the sport supports the requested endpoint
To debug API calls, you can log the full request URL by modifying the client's doRequest method or adding logging middleware.
For API-specific questions, refer to the SportDevs API documentation. For SDK issues, check that your OpenAPI specification is up to date and regenerate the SDK if needed.
This SDK was generated automatically from the SportDevs OpenAPI specification. Do not edit the generated files manually.