Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    prakesha
    @prakesha
    Hi! Despite login and SWID info, I can't seem to pull the recent activity for 2020 through. Any help? len(activity) = 0 despite teams information showing up.
    Christian Wendt
    @cwendt94
    Hmm are you getting any errors when calling league.recent_activity()?
    prakesha
    @prakesha

    Hmm are you getting any errors when calling league.recent_activity()?

    No, when I print league.recent_activity(), I get "[]" as if it recognizes it should be an array or list but it's size 0.

    Christian Wendt
    @cwendt94
    Recent activity will only show free agency (add, drops), waivers (add, drops), and trades. If the activity is setting changes and non transactions then it could be empty. Also you will want to be using the latest package v0.8.1. What type of activity are you seeing in your league through ESPNs app or website?
    prakesha
    @prakesha
    image.png
    Currently the recent activity is seen through the ESPN website and app, consistenting of mostly trades.
    Christian Wendt
    @cwendt94
    That is really weird, is your league private or public?
    prakesha
    @prakesha
    I am not the owner but Make League Viewable to Public appears to be set to Yes. However, swid/espn_s2 should account for it if it is private, correct? I do know if I am not logged in to an ESPN account, I cannot see the recent activity.
    prakesha
    @prakesha

    Oh, trying it on another computer and I no longer see the espn_s2 cookie information... so maybe they changed this in addition to the login credentials access.

    At least this is true from the Application process of retrieving it. I found it in my cookies by manually searching them.

    Christian Wendt
    @cwendt94
    Correct if you have permission issues it would error and you need to have your credentials for recent activity. If you could run the package in debug mode (League(debug=True)) and then look at the logs when you run recent activity that could help me debug the issue.
    prakesha
    @prakesha
    ESPN API Request: url: https://fantasy.espn.com/apis/v3/games/FFL/seasons/2020/segments/0/leagues/[league#here]/communication/ params: {'view': 'kona_league_communication'} headers: {'x-fantasy-filter': '{"topics": {"filterType": {"value": ["ACTIVITY_TRANSACTIONS"]}, "limit": 25, "limitPerMessageSet": {"value": 25}, "offset": 0, "sortMessageDate": {"sortPriority": 1, "sortAsc": false}, "sortFor": {"sortPriority": 2, "sortAsc": false}, "filterDateRange": {"value": 1564689600000, "additionalValue": 1583110842000}, "filterIncludeMessageTypeIds": {"value": [178, 180, 179, 239, 181, 244]}}}'}
    ESPN API Response: {'topics': []}
    Christian Wendt
    @cwendt94
    Sorry for the late response, but I see the issue. The “filterDateRange” is last years date. I fixed that a couple months ago, have you updated to the latest version https://github.com/cwendt94/espn-api? If you install the latest that should fix the issue!
    prakesha
    @prakesha
    Thank you!
    Christian Wendt
    @cwendt94
    No problem!
    Troy Kauffman
    @TroyKman_twitter

    Hello,
    I am working with a private league that is a bid draft

    I am trying to pull the first pick -> player name and I am not getting anything to return.
    league.draft[1].playerName
    I can see bid amount and other things, but can't pull the name

    Christian Wendt
    @cwendt94
    Hmm that seems odd that everything else is correct but playerName. I will try to check it out in the next couple days!
    Troy Kauffman
    @TroyKman_twitter
    Thank you very much. Let me know if you would need anything from me
    Christian Wendt
    @cwendt94
    So I just checked a league I am in and I am able to see all of the player names. Is it just one draft pick that does not have the name or all of the picks?
    Troy Kauffman
    @TroyKman_twitter
    It is all of the draft picks
    Christian Wendt
    @cwendt94
    Okay so there must be a problem with the player map because the player name data is a look up of playerId. If you could post a little of the data when you run this command:
    league.player_map
    Emilio Garcia
    @4rm

    Hi all, I'm having trouble accessing my private league. I'm using my espn_s2 and swid cookies, but I'm still getting 401'd. My code is below:

    import requests
    cookies = {
        "swid":"{########-####-####-####-############}",
        "espn_s2":"##...##"
        }
    url = 'https://fantasy.espn.com/apis/v3/games/ffl/seasons/2020/segments/0/leagues/######'
    r = requests.get(url, cookies=cookies)

    Even if I enter the API URL into my browser I get told "You are not authorized to view this League." Are my cookies messed up, or does the API not work anymore? I'm still able to see my league through the ESPN site, so it's not like I shouldn't have access. Sorry, this is my first time trying this.

    Christian Wendt
    @cwendt94
    Do you get the same 401 error when using the League object? I’m thinking it’s either the wrong cookies or something is wrong with the request but from first glance the request looks fine
    Emilio Garcia
    @4rm
    Actually, I'm quite embarrassed — I'm in a fantasy basketball league, and didn't realize the link should be FBA instead of FFL 😬 Thanks for your help anyway!
    Christian Wendt
    @cwendt94
    Ahh no worries, glad you got it fixed!
    Troy Kauffman
    @TroyKman_twitter
    image.png
    @cwendt94
    This is what I get with the playermap
    Christian Wendt
    @cwendt94
    So it looks like the player map is populated and should be able to look of player name from their id. I don’t no why none of the draft names are showing. You could put a print statement here https://github.com/cwendt94/espn-api/blob/705725d164321a047fc7d786b4c8b4f71ad1ba13/espn_api/football/league.py#L63 and see if it’s finding the player id and setting the player name
    Troy Kauffman
    @TroyKman_twitter
    I tried that originally, and I was able to return the player id of each player but it wouldn't return their name. That was how I was going to do the work around, was try and lookup playerid but didn't know how to reference with playermap, because I didn't think all of the playermap was populating (since it was ending with Josh Allen). I ended up just doing a for loop on each team in the league and looked for them in each roster. If you know of a way to search for a playerid in the playermap that would probably be more concrete (so if someone were to drop a player, I could still find them back)
    Christian Wendt
    @cwendt94
    Here is the call to ESPN’s API to get all of the players https://github.com/cwendt94/espn-api/blob/master/espn_api/base_league.py#L72 you could print out the data and make sure the player map is being populated correctly in that function. And this is for the 2020 season right?
    Troy Kauffman
    @TroyKman_twitter
    That is correct
    Christian Wendt
    @cwendt94
    Okay so I think the issue is for some reason the x-fantasy-filter header is not being applied when getting all of the players. If I call https://fantasy.espn.com/apis/v3/games/ffl/seasons/2020/players?view=players_wl without the x-fantasy-filter it shows the exact same players that you had in your player map. Are you using the latest package version?
    Troy Kauffman
    @TroyKman_twitter
    I thought that I was. What is the easiest way to check?
    Christian Wendt
    @cwendt94
    You could run: pip show espn_api
    Troy Kauffman
    @TroyKman_twitter
    sorry for the long delay in responding:
    I just reinstalled the api and am running: 0.10.0
    Christian Wendt
    @cwendt94
    No worries! Man that is so strange because that call should be the same for every league. Does you league have any special rules or settings? Or is it pretty normal?
    Cole
    @ColeGreyTea_twitter
    Hi, I'm using your project as a reference for a fantasy bball bot I'm building. Do you know if it's possible to get rankings per conference?
    All I see available in the data I'm looking at is playoff seed
    Christian Wendt
    @cwendt94
    Yeah I should be able to add that! I think ESPNs API provides that information!
    amirbh1106
    @amirbh1106
    hay guys im trying to get my box score and getting error
    image.png
    im new to python
    ProgrammerMatt
    @ProgrammerMatt
    where's this project stand for baseball?
    using the example on the README, I get No module named 'espn_api.baseball'
    hmm nvm. think I just had an old version.
    Christian Wendt
    @cwendt94
    Nice, glad it is working!
    Dominic Bardele
    @dbardele

    Hello, new to this forum and found it after working on an error I get trying to pull from the players_wl view in a 2022 espn ff league. When I run it without 'x-fantasy-filter': '{“filterActive”:null}' in my headers, my get request works because I believe I'm only pulling about the first 50 players.

    However, I would like to pull all the players so I include the line above but then I get this error: UnicodeEncodeError: 'latin-1' codec can't encode character '\u201c' in position 1: ordinal not in range(256)

    I've looked at many different suggestions that come up on stackoverflow and other sites, but I can't get anything to work.

    Has anyone pulled player data from this view before? Any suggestions will be appreciated!

    ffl_api = (
    "https://fantasy.espn.com/apis/v3/games/ffl/seasons/2022/segments/0/leagues/LEAGUENUMBER"
    )
    headers = {
    'Connection': 'keep-alive',
    'Accept': 'application/json, text/plain, /',
    'x-fantasy-filter': '{“filterActive”:null}',
    'x-fantasy-platform': 'kona-PROD-1dc40132dc2070ef47881dc95b633e62cebc9913',
    'x-fantasy-source': 'kona',
    'Content-Type': 'text/text; charset=utf-8'
    }
    r = requests.get(
    ffl_api,
    cookies={
    "swid": "{SWID}",
    "espn_s2": "cookie",
    },
    params={"view": "players_wl"},
    headers=headers,
    )
    Dominic Bardele
    @dbardele
    As expected, clearly my fault...nothing to do with encoding or anything. I changed this line from this 'x-fantasy-filter': '{“filterActive”:null}' to this 'x-fantasy-filter': '{}' and I got a huge json file which I'm hoping is all of the players in the league.
    Christian Wendt
    @cwendt94
    🔥 glad you were able to figure it out!
    If you run into anymore issues or just trying to do certain things with ESPN APIs I would suggest using the repos discussion page! I have been slowly moving away from glitter and have been using GitHub’s built in functionality. Better chance people will see it!