Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
How to make POST request using NodeJS with Yahoo! Fantasy Sports API

I'm trying to understand how to make a POST request to the Yahoo! Fantasy Sports API from my Express server, but having trouble understanding how to approach this given the documentation is written with PHP. Developing locally, I can easily authenticate the user and send all the GET requests I need using the nifty yahoo-fantasy api client developed by @whatadewitt.

I've tried the following to no avail:

  1. Using the api method on the main class of the yahoo-fantasy api client which ends up looking something like this on my Express server: const response = await yf.api('POST', 'https://fantasysports.yahooapis.com/fantasy/v2/league/${league_key}/transactions', options);
  2. Using axios to handle the https request
  3. Google searching for potential solutions until my eyes started burning
  4. Banging head against wall

Does anyone have any experience with using NodeJS to access Yahoo! Fantasy Sports API? I know this is pretty specific, but hoping someone has experienced this or something like it and can suggest some potential paths to consider.

Thanks!


[Edit in response to Luke Poirrier, who asked to see some code from my express index.js file]

There's not too much to it at the moment. Beyond requiring dependencies and going through oauth2.0 flow, I send the user to the /oauth-complete endpoint, which then begins making GET requests to get information about their game, league, team, etc. Truncated some code, but this should give you an idea of where I am:

app.get('/oauth-complete', async (req, res) => {
  // DELETED CODE THAT SETS REFRESH TOKEN IF NEEDED
  try {
    const sport = 'nfl';
    const { leagues } = (await yf.user.game_leagues(sport)).games[0];
    const { league_key } = leagues[0][0];
    const response = await yf.api('POST', `https://fantasysports.yahooapis.com/fantasy/v2/league/${league_key}/transactions`);
    console.log('response :>> ', response);
  } catch (err) {
    console.error(err);
  }
});

And here is the error message I'm getting in my terminal:

{
  'xml:lang': 'en-us',
  'yahoo:uri': '/fantasy/v2/league/406.l.1087313/transactions?format=json',
  description: 'unsupported content type . only application/xml supported',
  detail: ''
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!