steamcom
steamcom copied to clipboard
create_buy_order not working
File "F:\BUFF\Buy_Bot\test.py", line 31, in main market = steam_client.market.create_buy_order(app_id='730', market_hash_name=market_hash_name, price_single_item=buy_price, quantity=buy_quantity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\BUFF\Buy_Bot\venv\Lib\site-packages\steamcom\utils.py", line 21, in func_wrapper return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\BUFF\Buy_Bot\venv\Lib\site-packages\steamcom\market.py", line 126, in create_buy_order response = api_request(self.session, url, headers=headers, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\BUFF\Buy_Bot\venv\Lib\site-packages\steamcom\utils.py", line 276, in api_request raise ApiException(f'HTTP status code: {response.status_code}') steamcom.exceptions.ApiException: HTTP status code: 400
/
market_hash_name = "G3SG1 | Dream Glade (Minimal Wear)"
buy_quantity = 1
buy_price = "20"
username = 'xxxxxxxxxx'
password = 'xxxxxxxx'
shared_secret = 'xxxxxxxxxxxxx'
identity_secret = 'xxxxxxxxxxxxxxxxxx'
steam_client = SteamClient(username, password, shared_secret, identity_secret)
steam_client.login()
market = steam_client.market.create_buy_order(app_id='730', market_hash_name=market_hash_name, price_single_item=buy_price, quantity=buy_quantity)
Hi! I had this error too! As I understood here the problem is in quantity=buy_quantity, values greater than 2 give an error.
Hi! I had this error too! As I understood here the problem is in quantity=buy_quantity, values greater than 2 give an error.
When 1 also error. But everything is fine with the old device and ip, this error is only when logging into the account, either from the new ip, or the device, or together
I have already tested it a little, most likely the problem is that not all cookies are received when logging in. As soon as I have time, I'll take it up.
I have fixed my error. The problem was that I was sending an invalid floating point value to the function. Although then it is strange why it worked with values 1,2...
I tried to correct this error in Steampy
def create_buy_order(
self,
market_name: str,
price_single_item: str,
quantity: int,
game: GameOptions,
currency: Currency = Currency.USD,
) -> dict:
data = {
'sessionid': self._session.cookies.get_dict("steamcommunity.com")['sessionid'], #<<-------------------
'currency': currency.value,
'appid': game.app_id,
'market_hash_name': market_name,
'price_total': str(Decimal(price_single_item) * Decimal(quantity)),
'quantity': quantity,
}
headers = {
'Referer': f'{SteamUrl.COMMUNITY_URL}/market/listings/{game.app_id}/{urllib.parse.quote(market_name)}'
}
response = self._session.post(f'{SteamUrl.COMMUNITY_URL}/market/createbuyorder/', data, headers=headers).json()
return response
def set_sessionid_cookies(self):
community_domain = SteamUrl.COMMUNITY_URL[8:]
store_domain = SteamUrl.STORE_URL[8:]
community_cookie_dic = self.session.cookies.get_dict(domain=community_domain)
store_cookie_dic = self.session.cookies.get_dict(domain=store_domain)
for name in ('steamLoginSecure', 'sessionid', 'steamRefresh_steam', 'steamCountry'):
cookie = self.session.cookies.get_dict()[name]
if name in ["steamLoginSecure"]:
store_cookie = create_cookie(name, store_cookie_dic[name], store_domain)
else:
store_cookie = create_cookie(name, cookie, store_domain)
if name in ["sessionid", "steamLoginSecure"]:
community_cookie = create_cookie(name, community_cookie_dic[name], community_domain)
else:
community_cookie = create_cookie(name, cookie, community_domain)
self.session.cookies.set(**community_cookie)
self.session.cookies.set(**store_cookie)