Skip to main content

Get skin price history Steam API

I have this code, but for some reason the request to get information about the item on the marketplace does not work for me.

response has status_code = 200 but content = b'{"success":false}'

from base64 import b64encode

import requests
import rsa as rsa

# Creating a session
s = requests.session()

# Get the RSA key
response = s.get('https://steamcommunity.com/login/getrsakey/?username=USERNAME')
rsa_key = response.json()

# Create a public key
public_key = rsa.PublicKey(int(rsa_key['publickey_mod'], 16), int(rsa_key['publickey_exp'], 16))

# Encrypt password
password = 'PASSWORD'
password_encrypted = b64encode(rsa.encrypt(password.encode(), public_key)).decode()

# Log in
response = s.post('https://steamcommunity.com/login/dologin/',
                  data={'username': 'USERNAME',
                        'password': password_encrypted,
                        'twofactorcode': '',
                        'emailauth': '',
                        'loginfriendlyname': '',
                        'captchagid': '-1',
                        'captcha_text': '',
                        'emailsteamid': '',
                        'rsatimestamp': '',
                        'remember_login': False,
                        'donotcache': '',
                        'login': 'Sign in'})

# Obtaining price history
item_name = "Glove Case"
url = f"https://steamcommunity.com/market/pricehistory/?appid=730&market_hash_name={item_name}"
response_item = s.get(url)

if response_item.status_code == 200:
    data = response_item.json()
    for item in data:
        print(f"Price for {item['timestamp']} - {item['price']} USD")
else:
    print(f"Error {response_item.status_code}: {response_item.reason}")

I expect to receive the price of item for every day.

I need to execute a query that is executed only when there is a login: https://steamcommunity.com/market/pricehistory/?appid=730&market_hash_name=Glove%20Case

Documentation: https://github.com/Revadike/InternalSteamWebAPI/wiki/Get-Market-Price-History



source https://stackoverflow.com/questions/76222776/get-skin-price-history-steam-api

Comments