kevinskyba / kickbase-api-python

MIT License
22 stars 7 forks source link

Kickbase-API returns incorrect market values for 2. Bundesliga #6

Open LukeS28 opened 1 year ago

LukeS28 commented 1 year ago

Hey,

I’m currently using the Kickbase-API for my own little programming project creating a webapp, that delivers insights about market value development for the 2. German Bundesliga. However, I noticed that for a few weeks now, the market values seem to be incorrect.

For example, almost all HSV players return a market value of 500.000: This is what my code looks like:

from kickbase_api.kickbase import Kickbase
import pandas as pd
kickbase = Kickbase()
df = pd.DataFrame()
team = kickbase.team_players(6)
for j in range(0,len(team)):
            temp = pd.DataFrame([[team[j].id, team[j].team_id, team[j].first_name, team[j].last_name, team[j].market_value]],
                        columns=['ID','TeamID','Vorname',"Nachname","Marktwert"]                 
                       )
            df = df.append(temp)

df = df.set_index("ID")
df.TeamID = pd.to_numeric(df.TeamID)
df.index = pd.to_numeric(df.index) 
df

And this is the output: image

Do you have any idea what could be the reason for this?

Thank you & Best Regards LukeS28

Toubeyas commented 1 year ago

Hello, I looked into this as I am also using this python module for a personal 2nd Division project and it seems that this is an issue of the underlying kickbase API. It also happens with a lot of Hertha BSC players and more. If I see correctly these are values from when the players maybe used to be in the 1st Division, which is why the lowest value is 500k and not 250k. The endpoint also seems to mix the actual values with the wrong one, so I would recommend not using the .team_players() method to receive market values.

Temp Fix: for the correct Market Values I currently use a manual request to the API described in https://kevinskyba.github.io/kickbase-api-doc/index.html#request-player-player-stats . This gives the correct values for each player, even in the 2nd Division. I'm planning to also create a Pull Request for this endpoint, but I am currently not sure if the owner is still active to review them.

Best Regards Toubeyas

LukeS28 commented 1 year ago

Hey Toubeyas,

thank you for your reply! I've tried using the regular API (HTTP) to fetch Marketvalues with 'Player Stats'. However I'm having trouble with authentication. Every HTTP Request I've tried returns either Status 403 (Forbidden) when trying a GET request or Status 401 (Unauthorized) when trying to POST a login. Do you know how authentication works?

Thank you & Best Regards LukeS28

Toubeyas commented 1 year ago

Hey LukeS28,

I just used the method _do_get() from this package, as it already correctly implements the authentication via cookie. If you want to write your own api method, I would recommend looking into the code of the _do_get() and login() methods.

Best Regards Toubeyas

LukeS28 commented 1 year ago

Hey Toubeyas,

thank you! I managed to get it to work with player_stats. However the_do_get() function doesn't automatically recognize the token after login(), as I presume it is intended. I'm now manually retrieving the token with auth_cookie() and using it in the header of the request function and this works perfectly. I can now retrieve the complete market value history for any player!

Thank you so much for helping me with the solution!

Thanks & Best Regards LukeS28

FlexcelB commented 1 month ago

Hi,

I know this issue is quite old, but I'm experiencing a similar problem. I used the team_players endpoint to retrieve a list of all players per team (along with their player IDs) and then used the player_stats endpoint for individual market values. However, it seems that the team_players endpoint now only returns teams from the first division instead of the second division.

Is there another way to get a list of all relevant player IDs from the second division?

Thanks in advance, Flex