Good day !
To work with the Steam marketplace, I use the Steampy library from Bukson.
It did not have the function I needed to create the itemordershistogram
request, so I created it myself in the market.py
file.
The problem is that the server responds with a 400
error, saying that the request was incorrectly composed.
I created the function similarly to others, so I can’t understand what the problem is ...
I am attaching the code with my function from market.py
:
@login_required
def fetch_orders_histogram(self) -> dict:
url = SteamUrl.COMMUNITY_URL + '/market/itemordershistogram/'
params = {'country': 'RU',
'language': 'russian',
'currency': 1,
'item_nameid': 14962984,
'two_factor': 0}
response = self._session.get(url, params=params)
if response.status_code == 429:
raise TooManyRequests("You can fetch maximum 20 prices in 60s period")
if response.status_code != 200:
raise ApiException("http error code: %s" % response.status_code)
return response.json()
And here is the code from Python
:
from steampy.client import SteamClient
import time
steam_client = SteamClient('api-key')
steam_client.login("log", "pass", "steam_guard.json")
is_session_alive = steam_client.is_session_alive()
if(is_session_alive):
print("Successfully logged in")
else:
print("Error")
time.sleep(3)
resp = steam_client.market.fetch_orders_histogram()
print(resp)
After executing the code, it gives an error:
steampy.exceptions.ApiException: http error code: 400
If you execute the request through the browser, then everything works as it should...
Friends, tell me, please, what is wrong in my request? What to fix?
Thank you very much in advance !
Remove the trailing /
from your URL.
Line 3 should read:
url = SteamUrl.COMMUNITY_URL + '/market/itemordershistogram'