Skip to content

Instantly share code, notes, and snippets.

@dtcarls
Last active July 13, 2022 12:58
Show Gist options
  • Save dtcarls/c6158cd8ad41e0941571807052098a0f to your computer and use it in GitHub Desktop.
Save dtcarls/c6158cd8ad41e0941571807052098a0f to your computer and use it in GitHub Desktop.
Get espn auction adp and put in csv
import urllib.request
import json
import csv
req = urllib.request.Request('https://fantasy.espn.com/apis/v3/games/ffl/seasons/2021/segments/0/leaguedefaults/3?view=kona_player_info')
req.add_header('x-fantasy-filter','{"players":{"filterSlotIds":{"value":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,23,24]},"limit":150,"offset":0,"sortAverageAuction":{"sortAsc":false,"sortPriority":1},"sortDraftRanks":{"sortPriority":100,"sortAsc":true,"value":"STANDARD"},"filterRanksForScoringPeriodIds":{"value":[1]},"filterRanksForRankTypes":{"value":["PPR"]},"filterRanksForSlotIds":{"value":[0,2,4,6,17,16]},"filterStatsForTopScoringPeriodIds":{"value":2,"additionalValue":["002021","102021","002020","022021"]}}}')
with urllib.request.urlopen(req) as url:
data = json.loads(url.read().decode())
print(data)
with open('adp.txt','w') as outfile:
json.dump(data,outfile)
with open('adp.txt') as json_file:
with open('aucionval.csv', mode='w') as auction_file:
auction_file.write("Name,Value")
auction_file.write('\n')
data = json.load(json_file)
for person in data['players']:
if person['player']['ownership']['auctionValueAverage'] > 1:
auction_file.write(person['player']['fullName']+","+str(person['player']['ownership']['auctionValueAverage']))
auction_file.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment