Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
/ odds-api-go Public archive

(Unofficial) Go client library for the-odds-api

License

Notifications You must be signed in to change notification settings

fischersean/odds-api-go

Repository files navigation

This project has migrated to sourcehut

odds-api-go

Go Reference

Unofficial Go client library for the-odds-api.

Install

import "github.com/fischersean/odds-api-go"

Then run go mod tidy

Usage

Getting valid sports

package main

import (
	"fmt"
	"github.com/fischersean/odds-api-go"
)

func main() {
	c := oddsapi.NewClient("YOUR API KEY HERE")
	s, err := c.GetSports(oddsapi.GetSportsInput{
		IncludeInactive: false,
	})
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	fmt.Println(s)
}

Getting events data

package main

import (
	"fmt"
	"github.com/fischersean/odds-api-go"
)

func main() {
	c := oddsapi.NewClient("YOUR API KEY HERE")
	s, err := c.GetEvents(oddsapi.GetEventsInput{
		Sports:  []string{"americanfootball_nfl"},
		Regions: []oddsapi.RegionType{oddsapi.RegionUS},
		Markets: []oddsapi.MarketType{oddsapi.MarketMoneyline},
	})
	if err != nil {
		fmt.Println(err.Error())
        	return
	}
	fmt.Println(s)
}