GithubHelp home page GithubHelp logo

bukson / steampy Goto Github PK

View Code? Open in Web Editor NEW
542.0 23.0 149.0 164 KB

A Steam trading library for python 3

License: MIT License

Python 100.00%
steam steam-trade-offers steamguard steam-api windows linux macos python python3 steam-market

steampy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steampy's Issues

Bad practice with generate_one_time_code

Not so long ago, I came across the fact that with two-factor authentication comes empty response (#53). It turned out that if you authorize the client several times without restarting application, the same one-time code will be generated. It's a bad idea to pass a variable like time.time() to the default value:

def generate_one_time_code(shared_secret: str, timestamp: int = int(time.time())) -> str:
    # generating one-time code

Probably, it should look like this:

def generate_one_time_code(shared_secret: str, timestamp: int = 0) -> str:
    if not timestamp:
        timestamp = int(time.time())
    # generating one-time code

How to get a certain amount of an item?

So, I want to send a trade offer with 300 steam gems in it. But when I use Asset, it only wants the id of the item. How am I supposed to get a certain amount of that item?

Refactor tests

Delete some hard coded ids, and make some utility methods for fetching first item of me and partner

Relogin problem...

I have 24/7 bot with your greate lib. From time to time session die and iht's bot can't send/accept trades. If bot relogin in cycle, login failed. When i off program and run again login true, how to relogin without stopping program?

[Help] Cannot run storehouse.py

I cant run it. Using my own script and doing bot.login() also does not work. It constantly gives this error:

This is the donation bot accepting items for free.
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/usr/local/lib/python3.5/dist-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/jensen/Desktop/storehouse.py", line 47, in
main()
File "/home/jensen/Desktop/storehouse.py", line 21, in main
client.login(username, password, steamguard_path)
File "/usr/local/lib/python3.5/dist-packages/steampy/client.py", line 76, in login
LoginExecutor(username, password, self.steam_guard['shared_secret'], self._session).login()
File "/usr/local/lib/python3.5/dist-packages/steampy/login.py", line 26, in login
self._perform_redirects(login_response.json())
File "/usr/local/lib/python3.5/dist-packages/steampy/login.py", line 81, in _perform_redirects
parameters = response_dict['transfer_parameters']
KeyError: 'transfer_parameters'

SyntaxError

Well when I want to start my program this error pops up

Traceback (most recent call last):
  File "C:/Users/edast/Desktop/steam python/fetching_inv.py", line 1, in <module>
    from steampy.client import SteamClient
  File "C:\Python27\lib\site-packages\steampy\client.py", line 23
    def __init__(self, asset_id: str, game: GameOptions, amount: int = 1) -> None:
                               ^
SyntaxError: invalid syntax

My code

from steampy.client import SteamClient
from steampy.utils import GameOptions
from getpass import getpass

userName = raw_input("Steam name: ")
password = getpass("Password: ")
authCode = raw_input("Steam 2FA Code: ")

steam_client = SteamClient("Api key")
steam_client.login(userName, password, authCode)
partner_id = "FriendsId"
game = GameOptions.CS
partner_items = steam_client.get_partner_inventory(partner_id, game)
print(partner_items)
steam_client.logout()

steam_client instead of client in readme.md

from steampy.client import SteamClient, Asset
from steampy.utils import GameOptions

steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
partner_id = 'PARTNER_ID'
game = GameOptions.CS
my_items = client.get_my_inventory(game)
partner_items = client.get_partner_inventory(partner_id, game)
my_first_item = next(iter(my_items.values()))
partner_first_item = next(iter(partner_items.values()))
my_asset = Asset(my_first_item['id'], game)
partner_asset = Asset(partner_first_item['id'], game)
client.make_offer([my_asset], [partner_asset], partner_id, 'Test offer') 

I think in this block everywhere should be steam_client instead of client.

New version 0.40!

This versions add Ermans implementation of steam market api.

It is still a bit experimental so use it carefully. please inform me about issues/bugs that can occur.

This change brakes backawards compatibility, i am aware that this is young library and i can happen, To version 1.0 it can happen some times, I will try to avoid it if possible.

[Question/Bug] Is it not possible to use steam and steampy in the same execution?

So, I want to send a trade when the bot gets a certain message, so I'm using the steam modual and steampy for trading, however, I got past the first bug, where you need to add

import gevent.monkey
gevent.monkey.patch_socket()
gevent.monkey.patch_ssl()

before importing it, so the login goes smoothly. However, after the steam login, it states invalid credentials, whilst even though I used the same ones to log into steam, I can't log into steampy with them? Is there some sort of issue with connecting to steam with 2 different programs? If I have steampy and steam running in separate files, it runs fine, but if it's in the same, theirs issues. Does anyone know why this is happening?

Insert auth code manually

Hey mate, nice work.
I was playing with the module and can't get the code working without the steamguard file, I ran into some errors. I don't have much experience in python and don't know how to do this.

Bug - Expected Trade confirmation

After adding the updated version of steampy, the bot accepted the trade, but stopped the loop due to an expected trade confirmation:

raise ConfirmationExpected
steampy.confirmation.ConfirmationExpected

The items, like last time, went through successfully, however still created this error

login problem

use SDA as from it to get files, try maFaile does not work

Error with make_offer

make offer response return error 15

asset_partn = Asset(item['id'],game)
response = steam_client.make_offer([],[asset_partn],partnerid,"Please))")
print(response)

Shared_secret file

Is there some way to not use the file with secrets but type in steam guard authentication code every time when I want to login?

InvalidCredentials with empty message while logging

In response to two-factor authorization, I get an error with a mixed message. Here's the log:

2017.05.15 16:15:48 [app.DEBUG][26745 140737041318848] Response for steam auth: 
{"success":false,"requires_twofactor":true,"message":""} (login.py:28)
2017.05.15 16:15:50 [app.DEBUG][26745 140737041318848] Response for steam two-factor auth: 
{"success":false,"requires_twofactor":true,"message":""} (login.py:31)

What am I doing wrong?

Make offer except

Partner_id is Steam64 or AccountID? When i use this method with AccID and Stean64 i get error KeyError: 'rgInventory'

Make offer don't work

Make offer return 401 status and None response when i do make_offer or make_offer_with_trade_url

Change GameOptions enum to normal class

So, I'm trying to get my steam backpack. It's one of those sub-inventory backpacks, so I have the context_id = '6'

>>>GameOptions('753','6')

But I get the error:

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    steam = GameOptions('753','6')
  File "C:\Users\Zwork101\AppData\Local\Programs\Python\Python36-32\lib\enum.py", line 293, in __call__
    return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
  File "C:\Users\Zwork101\AppData\Local\Programs\Python\Python36-32\lib\enum.py", line 378, in _create_
    _, first_enum = cls._get_mixins_(bases)
  File "C:\Users\Zwork101\AppData\Local\Programs\Python\Python36-32\lib\enum.py", line 436, in _get_mixins_
    raise TypeError("Cannot extend enumerations")
TypeError: Cannot extend enumerations

I don't see what i'm doing wrong, help?

[Discussion] About the Steam Market

(talking to bukson the author of this library)
I have made for myself some function to handle the Steam Market.
I'm talking about creating a buy order or a sell listing and removing them (confirmation with steamguard included).

Is it your plan to have them in this library?

I can make a pull request if you agree, I just need to make the functions more general because now are crafted right for my code and to make some tests.

Is make offer working?

So, I have the following code to send and offer:

print(itemList)
print([gems])
print(str(friend.steam_id))
steam_client.make_offer(itemList,[gems],str(friend.steam_id))
friend.send_message("Alrighty! Sending your trade right now!")
print("sent trade offer!")

And it returns this:

[<steampy.client.Asset object at 0x039B7AB0>, <steampy.client.Asset object at 0x03A2D590>, <steampy.client.Asset object at 0x04868E50>, <steampy.client.Asset object at 0x0489A310>, <steampy.client.Asset object at 0x0489A130>, <steampy.client.Asset object at 0x0489A1B0>, <steampy.client.Asset object at 0x0489A350>, <steampy.client.Asset object at 0x0489A1D0>, <steampy.client.Asset object at 0x05AE3930>, <steampy.client.Asset object at 0x0489A330>, <steampy.client.Asset object at 0x05AE3B90>, <steampy.client.Asset object at 0x05AE39D0>, <steampy.client.Asset object at 0x05AE3710>, <steampy.client.Asset object at 0x05AE3BB0>, <steampy.client.Asset object at 0x05AE32F0>, <steampy.client.Asset object at 0x05AE3050>, <steampy.client.Asset object at 0x05AE3810>, <steampy.client.Asset object at 0x05AE3C70>, <steampy.client.Asset object at 0x05AE3910>, <steampy.client.Asset object at 0x05AE3A90>, <steampy.client.Asset object at 0x05AE3AB0>]
[<steampy.client.Asset object at 0x04868FB0>]
76561198269569899
sent trade offer!

However, it does not, infact, end up sending the offer, and raises no errors. Is this something that is known, or have I done something incorrect?

accepting offer with giving items

Can`t accept offer where i giving some items to another person. Problem is _get_confirmations method, when it`s try to _fetch_confirmations_page it gets steam page with alert instead of valid confirmation page

Hi I am getting an error

Hi the title says it all
My error:

Unhandled exception in thread started by <function processingOrder at 0x04AEDDB0>
Traceback (most recent call last):
  File "C:\Users\edast\Desktop\steam python\Bot\KeyToGamesP2.py", line 150, in processingOrder
    print partner_items[item]["type"]
TypeError: 'bool' object has no attribute '__getitem__'

And code:

    partner_id = msg.body.steamid_from
    partner_items = steam_client.get_partner_inventory(partner_id, game)
    hasKey = False
    keysToOrder = False
    for item in partner_items:
        print(item)
        if not item == "success" or not item == "rgInventory":
            print partner_items[item]["type"]
            if partner_items[item]["type"] == "Base Grade Container":
                print("Went thru")
                if partner_items[item]["tradable"] == 1 and partner_items[item]["marketable"] == 1:
                    print("Ma klic. Posilam offer...")
                    if len(klice) >= keyCount:
                        keysToOrder = True
                        break
                    else:
                        klice.append(item)
                        hasKey = True

Error with sha1.new

After accepting the trade, and even receiving the item It traded for, the program exited the loop due to sha1 not having the attribute .new()

hexed_steam_id = sha1.new(steam_id.encode('ascii')).hexdigest()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'

So even though it completes the trade, this error still occurs.

Login returns False

When i try to login, i got this:
{'requires_twofactor': True, 'message': '', 'success': False}

way to send message

hi I want to know if there a function with this api to send messge to a friend in steam by his steamid ??

Problem with installation

After trying to download steampy through pip, but received this error, even after installing the C++ interpreter.

  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:\users\zwork101\appdata\local\programs\python\python36-32\include -Ic:\users\zwork101\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcsrc/winrand.c /Fobuild\temp.win32-3.6\Release\src/winrand.obj
    winrand.c
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier 'rem'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: syntax error: '}'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier 'imaxdiv_t'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ')' before identifier '_Number'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier '_Number'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: syntax error: ')'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ')' before identifier '_Numerator'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier '_Numerator'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ','
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: syntax error: ')'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: syntax error: missing '{' before '__cdecl'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

Does any one know Why? or How I can fix it?

Masters degree

Hi.

I am finishing my masters degree and have not so much time for steampy. It will change soon, now I will try to answert support questions, but development and code review will be done after 2 weeks.

Sorry for inconvinience.

I will close this issue when i finish my masters degree program

Windows Support

Cool library!

Still there is an issue for Windows users which i noticed today with someone in the discord chat of r/steambot. PyCrypto is not installable in an easy way on Windows so i propose to remove the dependency on the packages and implement a native approach. As reference you could take the C# class from here.

Its just a suggestion and would make a lot of things easier for the Windows folks (i am using ubuntu/windows and .net core, so not likely a python guy).

[Request] Log in a site using "Sign in through Steam"

Is it possible to add the possibility to login in a site through the green button "Sign in through Steam" and keep the session? Because I need to log in a site that uses SteamIDs.

Some example:
backpack.tf
dota2lounge.com
lootmarket.com

I really want to make some requests to these sites but I need a session but don't know how to do it.

Login method not handle steam errors.

I got an error:

Traceback (most recent call last):
  File "C:\YandexDisk\my_python_progs\csgo\new\tests\test_main.py", line 15, in <module>
    import libs.helpers as helpers
  File "C:\YandexDisk\my_python_progs\csgo\new\libs\helpers.py", line 456, in <module>
    steam_client = login_steam(steam_login, steam_pass, steam_guard, steam_api_key)
  File "C:\YandexDisk\my_python_progs\csgo\new\libs\helpers.py", line 319, in login_steam
    steam_client.login(steam_login, steam_pass, steam_guard)
  File "C:\Users\vasis\AppData\Local\Programs\Python\Python35\lib\site-packages\steampy\client.py", line 76, in login
    LoginExecutor(username, password, self.steam_guard['shared_secret'], self._session).login()
  File "C:\Users\vasis\AppData\Local\Programs\Python\Python35\lib\site-packages\steampy\login.py", line 26, in login
    self._perform_redirects(login_response.json())
  File "C:\Users\vasis\AppData\Local\Programs\Python\Python35\lib\site-packages\steampy\login.py", line 82, in _perform_redirects
    parameters = response_dict['transfer_parameters']
KeyError: 'transfer_parameters'

I put print in _perform_redirects method, and get response_dict content in moment of error:

{'success': False, 'requires_twofactor': False, 'message': 'There have been too many login failures from your network in a short time period. Please wait and try again later.', 'captcha_gid': -1, 'captcha_needed': False}

Can you improve login method to handle this errors?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.