Documentation ¶
Overview ¶
Package gocflapi provides a client for the CFL API (http://api.cfl.ca/docs).
The client was generated using the https://github.com/swagger-api/swagger-codegen project from a hand-written Swagger 2.0 spec file (https://github.com/greglanthier/gocflapi/blob/master/api/cflapi.yaml).
Example ¶
Here is an example of using the swagger-codegen generated client to retrieve game data for all the games in the 2018 season.
package main import ( "context" "fmt" "os" "time" cflapi "github.com/greglanthier/gocflapi/pkg/client" _ "github.com/joho/godotenv/autoload" ) func main() { // import ( // "context" // "fmt" // "os" // "time" // cflapi "github.com/greglanthier/gocflapi/pkg/client" // _ "github.com/joho/godotenv/autoload" // load environment variable // // _ "github.com/motemen/go-loghttp/global" // Uncomment for degug logging of HTTP traffic. // ) ctx := context.Background() ctx, cancel := context.WithTimeout(ctx, 1000*time.Millisecond) defer cancel() ctx = context.WithValue(ctx, cflapi.ContextAPIKey, cflapi.APIKey{Key: os.Getenv("CFL_API_KEY")}) config := cflapi.NewConfiguration() games, _, err := cflapi.NewAPIClient(config).GamesApi.GetGames(ctx, 2018) if err != nil { panic(err) } fmt.Println(len(games.Data)) }
Output: 95
Click to show internal directories.
Click to hide internal directories.