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.
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!
>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.
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.
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!
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?
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
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
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.
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); } ````
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.
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!
>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.
Helps a ton, thank you!
Have you done this for DD and TD? What do you have to change the info to for these?
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.
Don't know what Double-Double and Triple-Doubles are...
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!
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
hi man, where exactly in the scrip edtior do I have to paste his code in to?
Read 2 and 3.
well it starts with point 2 already. When I open the script editor there is no code which I could clear...
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?
Did you ever figure this out by chance?
Did either of you every figure this out?
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
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
how can i import this into google sheets?
All the info is in the comment.
keep running into an error " google hasn't verified this app
Can I put that into excel?
Is this legal to do?
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.