Looking for help with yahoo api

I’m hoping someone can walk me through a few different api calls to yahoo sports. Eric Kolada was nice enough to write up a snippet for their oauth2 process but I’m not capable (yet) of pulling / structuring data myself.

Willing to pay and anxious to learn the ways of pack building.

Can you post the code for what you’re got so far?

Is it the fantasy sports API? What kinds of data are you looking to read from / write to the API? What’s the result you’re looking for?

(Someone may reach out with direct support which is great, but we may also be able to set you on the right track on the community here)

At the moment writing back to the api isn’t a priority. Mostly looking to pull League and Team level data more so than players stats.

Here is a screen grab of Eric’s Oauth2…forum won’t let me post more than 2 links yet.

Below is a link to Yahoo’s documentation, however I believe its in PHP and I don’t quite grasp the difference between it and JavaScript.

Yahoo Documentation

Here is a quick mock-up of what I’d like to present in coda. I want users to enter their league id and then get back what’s in the mock-up for a historical view of their league.

Mock Up in Coda

Nice!

For something like Standings, what you want is a Sync Table with a League ID parameter. Users would enter that ID in the right panel in the settings for the table, and you’d fill the table with a list of all the teams and their data.

You’ll define a schema for your table (basically, what are the columns going to be).

You’ll have a sync formula that looks a bit like Eric’s getConnectionName formula, but you’ll build the URL like this:
url: "https://fantasysports.yahooapis.com/fantasy/v2/league/" + leagueId + "/standings"

You’ll go through and populate each column with the corresponding property that you got back from the API. To do this you’ll need to use a Javascript loop, e.g.

let rows = [];  // start with a blank array to hold all the rows
for (let team of response.body.standings.teams) {   // do the below for each team in the list of teams
  rows.push({ // add the following to the list of rows
    name: team.name,
    WLT: team.team_standings.outcome_totals.wins + "-" + team.team_standings.outcome_totals.losses + "-" + team.team_standings.outcome_totals.ties,
     // ...etc for other properties
  })
}

Let me know if these hints help! It’s a bit of a project but definitely doable. Feel free to keep posting code here as you work (best bet is to copy and paste the actual text, and use the format as code button).

I’m also a big fan of using console.log a lot to see what the API is giving back to you. e.g. after your fetch line, do: console.log(JSON.stringify(response.body)); to spit out everything the API said back to you into the logs. That way you’ll be able to see what’s included, and figure out how to grab what you need with dot notation (like I did above with team.team_standings.outcome_totals…).

Good luck!

3 Likes

Also I want to say - don’t be discouraged that you can’t understand the API documentation well. The docs for this API are surprisingly poor.

Many of the APIs I’ve worked with have examples in multiple languages, clearer explanations for what endpoints are available and what kind of data they return, and sometimes even offer a little interactive playground where you can try inputting things to see what it gives back.

These docs are pretty no-frills.

3 Likes