Skip to content

Instantly share code, notes, and snippets.

@kgravenreuth
Last active April 8, 2022 09:19
Show Gist options
  • Save kgravenreuth/a7a768a4875f4799112dbc22ac4b78d4 to your computer and use it in GitHub Desktop.
Save kgravenreuth/a7a768a4875f4799112dbc22ac4b78d4 to your computer and use it in GitHub Desktop.
Cloudbet API Sports Odds in Go
var markets []*bookmaker.Market
// traverse markets, e.g. soccer asian handicap
for marketKey, market := range event.GetMarkets() {
// traverse submarkets, e.g. soccer asian handicap ->
for submarketKey, submarket := range market.GetSubmarkets() {
// traverse selections, e.g. home team +0.5
for _, selection := range submarket.GetSelections() {
lineID := strings.TrimRight(fmt.Sprintf("%s/%s?%s", marketKey, selection.GetOutcome(), selection.GetParams()), "?")
fmt.Println("line id: %v", lineID)
fmt.Println("max bet: %v", selection.MaxStake)
fmt.Println("odds: %v", selection.Price)
fmt.Println("probability: %v", selection.Probability)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment