Advertisement
RemcoE33

ESPN - Golf

Feb 17th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ESPN_GOLF(){
  2.   const response = UrlFetchApp.fetch('https://site.web.api.espn.com/apis/v2/scoreboard/header?sport=golf&league=pga&region=us&lang=en&contentorigin=espn')
  3.   const data = JSON.parse(response.getContentText())
  4.  
  5.   const output = []
  6.  
  7.   data.sports[0].leagues[0].events[0].competitors.forEach((c, i) => {
  8.     const object = {
  9.       place: c.place,
  10.       winner: c.winner,
  11.       name: c.displayName,
  12.       firstname: c.firstName,
  13.       lastname: c.lastName,
  14.       shortname: c.shortName,
  15.       amount: c.amount,
  16.       officialAmount: c.officialAmount,
  17.       earnings: c.earnings,
  18.       score: c.score,
  19.       movement: c.movement,
  20.       status_period: c.status.period,
  21.       status_teeTime: c.status.displayValue,
  22.       status_hole: c.status.hole,
  23.       status_startHole: c.status.startHole,
  24.       status_thru: c.status.thru,
  25.       status_playoff: c.status.playoff,
  26.       status_state: c.status.state,
  27.       photo: c.headshot
  28.     }
  29.  
  30.     if (i == 0){
  31.       output.push(Object.keys(object))
  32.     }
  33.     output.push(Object.values(object))
  34.   })
  35.  
  36.   return output
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement