Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

famendola1/yfantasy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(Deprecated) Yahoo Fantasy API Client for Go

Go Reference License Go Report Card

Notice

This package has been replaced by the yfquery and yflib packages.

Installation

go get github.com/famendola1/yfantasy

Yahoo Endpoints

The Yahoo offical documentation for their Fantasy Sports API is not comprehensive and incomplete, despite being the offical. For a more complete overview of the supported endpoints, see the README.

Usage

There are two ways to interact with the Yahoo Fantasy API through this Go client:

  • Using high-level functions in api.go
  • Using the query builders in query/

Before You Start

Both of these usages require the use of a *http.Client that is configured for the Yahoo Fantasy API endpoint. You can use the github.com/famendola1/yauth package to configure a *http.Client to use.

High Level Functions

The high level functions in api.go provide additional functionality on top of the query builders. These functions can be accessed through the YFantasy struct. A valid YFantasy struct must be initialized with yfantasy.New prior to using these functions.

Contributions to set the high level functions provided through this client are welcome 🙂.

Query Builders

The query buiilders were designed to be able to easily generate queries for all the Yahoo Fantasy API endpoints. The builders expose functions that add pieces and parameters to the query. They also expose the following functions:

  • ToString: Builds the string for the query that the builder represents.
  • Get: Sends a GET request to the Yahoo Fantasy API for the endpoint that the query represents. A successful query will return a FantasyContent struct.

WARNING: The query builders do not validate that the queries they build are valid Yahoo endpoints.

Examples

// Get all the teams in a league.
Leagues().Key("nba.l.12345").Teams().Get(client)

// Search for a player and return their stats for the past week.
Leagues().Key("nba.l.12345").Players().Search("Donovan Mitchell").Stats().LastWeek().Get(client)

// Get all the leagues a user is in.
Users().Leagues().Get(client)

// Get the rosters for all teams in a league.
League().Key("nba.l.12345").Teams().Roster().Get(client)

// Get all the add and drop transactions in a league
League().Key("nba.l.12345").Transactions().Types([]string{"add", "drop"}).Get(client)

Projects using this client

A fantasy sports Discord bot is being developed with this client: https://github.com/famendola1/fantasy-discord-bot.

About

Go client for Yahoo Fantasy Sports API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages