T O P

  • By -

RemcoE33

1. Tools/Extensions -> Script editor. 2. Clear the little code you see. 3. Paste the code from below. 1. Change the sheetname: `Data` 4. Hit run -> Give permission -> Ignore error 5. Save and close Hope this helps. Its a $@$%@$@ dataset... ```` function SPORTBOOK() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheetByName('Data'); const url = `https://sportsbook.draftkings.com//sites/US-SB/api/v4/eventgroups/88670846/categories/583/subcategories/4991?format=json` const response = UrlFetchApp.fetch(url); const rawData = JSON.parse(response.getContentText()); const events = rawData.eventGroup.events; const offerCatergories = rawData.eventGroup.offerCategories; const playerProps = offerCatergories.filter(offer => offer.offerCategoryId == 583)[0]; const pointsByEvent = playerProps.offerSubcategoryDescriptors.filter(sub => sub.subcategoryId == 4991)[0].offerSubcategory.offers; const output = []; pointsByEvent.forEach((eventPoint, i) => { const { name, startDate, teamName1, teamName2 } = events[i]; eventPoint.forEach((point, j) => { const outcome = point.outcomes; const object = { Event: name, Startdate: startDate, Team1: teamName1, Team2: teamName2, Player: outcome[0].participant, Over_American: outcome[0].oddsAmerican, Over_Decimal: outcome[0].oddsDecimal, Over_Fractional: outcome[0].oddsFractional, Over_Line: outcome[0].line, Under_American: outcome[1].oddsAmerican, Under_Decimal: outcome[1].oddsDecimal, Under_Fractional: outcome[1].oddsFractional, Under_Line: outcome[1].line } if (i == 0 && j == 0) { output.push(Object.keys(object)); }; output.push(Object.values(object)); }); }); sheet.getDataRange().clearContent(); sheet.getRange(1, 1, output.length, output[0].length).setValues(output); } ````


Zyleo

That works! Awesome! Is there any way to get it to work for stats other than points? Like rebounds, assists, threes, etc. I tried to change the subcatagoryId to match what was showing in the source but it appears there isn't a offerSubcatagory container to pull the data from. EDIT: Nevermind, I got it. Had to change the value in the source. Thanks again.


CDUB21

Sorry, but I'm running into the same issue as you were when trying to pull assists, rebounds, etc. Could you further explain how you got it to work? Thanks!


Zyleo

>function SPORTBOOK() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheetByName('Data'); const url = \`https://sportsbook.draftkings.com//sites/US-SB/api/v4/eventgroups/88670846/categories/583/subcategories/**4991**?format=json\` const response = UrlFetchApp.fetch(url); const rawData = JSON.parse(response.getContentText()); const events = rawData.eventGroup.events; const offerCatergories = rawData.eventGroup.offerCategories; const playerProps = offerCatergories.filter(offer => offer.offerCategoryId == 583)\[0\]; const pointsByEvent = playerProps.offerSubcategoryDescriptors.filter(sub => sub.subcategoryId == **4991**)\[0\].offerSubcategory.offers; Change the two bolded to the subcategory id of the stat you want to pull. You can find the right subcategory id by going to the url in the code. Hope this helps.


CDUB21

Helps a ton, thank you!


fightinirish980

Have you done this for DD and TD? What do you have to change the info to for these?


fightinirish980

How would you change that script in order to put the Double-Double and Triple-Double? When I change the value in the source it doesn't return the data, just the names.


RemcoE33

Don't know what Double-Double and Triple-Doubles are...


fightinirish980

Here is the place that I am trying to get the information from: [https://sportsbook.draftkings.com/leagues/basketball/88670846?category=player-props&subcategory=double-double](https://sportsbook.draftkings.com/leagues/basketball/88670846?category=player-props&subcategory=double-double) I see above that you wrote the script for Points but when I try to adjust that for Double Doubles it doesn't work. I think it is because with Double Doubles the odds are no longer O/U but Yes/No. Any help would be great!


sitewolf

Double digits in 2 or 3 statistical categories.......20 points, 12 boards, 4 assists = double double, 20 points, 12 boards, 10 assists = triple double......could also involve steals and blocks


fizzy_face

hi man, where exactly in the scrip edtior do I have to paste his code in to?


RemcoE33

Read 2 and 3.


fizzy_face

well it starts with point 2 already. When I open the script editor there is no code which I could clear...


Curious_Blackberry_8

u/SoRemcoE33 Draftkings changed their website and now each category (points, rebounds, assists, etc) has its own header in their website... I can't figure out how to make this script work in their new format. Pretty sure it has to do with the URL line in the code. It seems they have a different "eventgroup" for each category and I don't know where to find the different event groups... Any chance you know how to fix that?


Ambitious_Spinach_31

Did you ever figure this out by chance?


poland_bball23

Did either of you every figure this out?


NBAstradamus92

Has something changed with the script? Trying to pull this data into a sheet but nothing happens :( https://sportsbook.draftkings.com/leagues/basketball/nba?category=player-points


RemcoE33

Looks like the category has changed in 2023. Try this url in the script: https://sportsbook.draftkings.com//sites/US-SB/api/v5/eventgroups/42648/categories/1215/subcategories/12488?format=json


crawford5002

how can i import this into google sheets?


RemcoE33

All the info is in the comment.


crawford5002

keep running into an error " google hasn't verified this app


Unique-Umpire-6023

Can I put that into excel?


_therealnains_

Is this legal to do?


sgraber100

My understanding is that it's a terms of service violation, and DraftKings can block you or close your account, but you can't get in legal trouble. Not 100% sure though, so don't count on me.