bukson / steampy

A Steam trading library for python 3
MIT License
565 stars 152 forks source link

create_sell_order #277

Open Spawn944 opened 1 year ago

Spawn944 commented 1 year ago

I'm having an issue creating sell order. How can i fix this?

import steampy
import json
from steampy.client import SteamClient
from steampy.exceptions import ApiException
from steampy.models import GameOptions

username = 'e'
password = 'w'
shared_secret_key = 'U'
API_KEY = '0'
steamid = '7'
identity_secret_key = 'w'

game = GameOptions(context_id=2, app_id=730)
money_to_receive = "25.00"

steamguard_data = {
    "steamid": steamid,
    "shared_secret": shared_secret_key,
    "identity_secret": identity_secret_key
}
steamguard_data = json.dumps(steamguard_data)
steam_client = SteamClient(API_KEY)
item_list_file = r"C:\Users\Kann\Desktop\Steam\Selling\items_for_sale.txt"
success_file = r"C:\Users\Kann\Desktop\Steam\Selling\items_sold_successfully.txt"

try:
    steam_client.login(username, password, steamguard_data)
    print("Successfully logged in to Steam.")

    with open(item_list_file, "r") as file:
        item_list = file.read().splitlines()

    while item_list:
        item = item_list[0] 

        try:
            response = steam_client.market.create_sell_order(item, game, money_to_receive)
            print(response)

            if response and response.get("success"):
                print(f"Successfully sold item: {item}")
                item_list.pop(0)  

                with open(success_file, "a") as success_file:
                    success_file.write(item + "\n")
            elif response and response.get("message"):
                print(f"Error occurred while selling item {item}: {response['message']}")
            else:
                print(f"Unknown error occurred while selling item {item}")

        except ApiException as e:
            print(f"Error occurred while selling item {item}: {e}")

    print("All items sold successfully!")

    with open(item_list_file, "w") as file:
        for item in item_list:
            file.write(item + "\n")

except ApiException as e:
    print(f"Error occurred while logging in to Steam: {e}")
finally:
    steam_client.logout()

output

C:\Users\Kann>python C:\Users\Kann\Desktop\Steam\Selling\sell_testing1.py
Successfully logged in to Steam.
{'success': False, 'message': 'Missing parameters in SellItem request'}
Error occurred while selling item Nova | Sand Dune (Minimal Wear): Missing parameters in SellItem request
{'success': False, 'message': 'Missing parameters in SellItem request'}
Error occurred while selling item Nova | Sand Dune (Minimal Wear): Missing parameters in SellItem request
{'success': False, 'message': 'Missing parameters in SellItem request'}
Error occurred while selling item Nova | Sand Dune (Minimal Wear): Missing parameters in SellItem request
Traceback (most recent call last):
  File "C:\Users\Kann\Desktop\Steam\Selling\sell_testing1.py", line 43, in <module>
    response = steam_client.market.create_sell_order(item, game, money_to_receive) 
woctezuma commented 1 year ago

Related:

No clue about that missing parameter though.

Dandelion101 commented 1 year ago

Try specifying the game differently game = GameOptions.DOTA2 Instead of item, specify item id

VnykBabyshki commented 6 months ago

There are two mistakes in your code:

Here is a sample from steam_client.get_my_inventory(game) in which I highlighted the assetid using arrows — >>assetid<<

{
">>36643205050<<": {
        "appid": 730,
        "classid": "5721076182",
        "instanceid": "188530170",
        ...
        "contextid": "2",
        "id": ">>36643205050<<",
        "amount": "1"
    },
    ">>36643162490<<": {
        "appid": 730,
        "classid": "5721067159",
        "instanceid": "188530139",
        ...
        "contextid": "2",
        "id": ">>36643162490<<",
        "amount": "1"
    }
}