Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

create_buy_order not working #6

Open
jjh4568520 opened this issue Mar 1, 2024 · 4 comments
Open

create_buy_order not working #6

jjh4568520 opened this issue Mar 1, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@jjh4568520
Copy link

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)
@LinarSharifullin LinarSharifullin added the bug Something isn't working label Mar 1, 2024
@camillo1990
Copy link

Hi! I had this error too! As I understood here the problem is in quantity=buy_quantity, values greater than 2 give an error.

@LinarSharifullin
Copy link
Owner

LinarSharifullin commented Mar 7, 2024

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.

@camillo1990
Copy link

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...

@jjh4568520
Copy link
Author

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)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants