A
A
anya_hacker2021-10-06 22:11:16
Python
anya_hacker, 2021-10-06 22:11:16

Why don't all items have a Steam warrant?

I place orders for items on Steam using this API: https://github.com/bukson/steampy#market-methods
I specify the api key of the account, login, password and the path to maFile on the computer.
When I specify an item from the Counter-Strike: Global Ofensive game (for example, a glove case item), then an order for this one is placed. But if I create an order for a Steam card, then an error occurs.
The code:

from steampy.client import SteamClient
from steampy.models import Currency
from steampy.utils import GameOptions

steam_client = SteamClient('4301...A')  # API_KEY

# USERNAME, PASSWORD, PATH_TO_STEAMGUARD_FILE
steam_client.login('xi...2', 'z...R2',
                   r'C:\Users\me\Desktop\steam desktop\SDA-1.0.10\maFiles\76561198877671188.maFile')

dict_orders_items = {}
item_name_1 = "Glove Case"
item_name_2 = "Urki"

# название предмета, цена в копейках, кол-во ордеров, тип игры (CS), валюта (рубли)
response = steam_client.market.create_buy_order(item_name_1, "100", 1, GameOptions.CS, Currency.RUB)
dict_orders_items[item_name_1] = response['buy_orderid']
print(dict_orders_items)

response = steam_client.market.create_buy_order(item_name_2, "100", 1, GameOptions.STEAM, Currency.RUB)
dict_orders_items[item_name_2] = response['buy_orderid']
print(dict_orders_items)

The order was created on the glove case:
615df4163be17737590371.png
And when creating the urki card on steam, an error occurs:
Traceback (most recent call last):
  File "C:\Users\me\PycharmProjects\steam api\question.py", line 20, in <module>
    response = steam_client.market.create_buy_order(item_name_2, "100", 1, GameOptions.STEAM, Currency.RUB)
  File "C:\Users\me\AppData\Local\Programs\Python\Python39\lib\site-packages\steampy\market.py", line 18, in func_wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\me\AppData\Local\Programs\Python\Python39\lib\site-packages\steampy\market.py", line 126, in create_buy_order
    raise ApiException("There was a problem creating the order. Are you using the right currency? success: %s"
steampy.exceptions.ApiException: There was a problem creating the order. Are you using the right currency? success: 42


This is the create_buy_order method (as you can see, in any error it will display that it doesn’t like the currency. Changed it to another, similar error. If there was a problem in the currency, it would not put a glove case on the ruble currency
@login_required
    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_id,
            "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': "%s/market/listings/%s/%s" % (SteamUrl.COMMUNITY_URL, game.app_id, market_name)}
        response = self._session.post(SteamUrl.COMMUNITY_URL + "/market/createbuyorder/", data,
                                      headers=headers).json()
        if response.get("success") != 1:
            raise ApiException("There was a problem creating the order. Are you using the right currency? success: %s"
                               % response.get("success"))
        return response

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question