woctezuma / steam-market

Find arbitrages on the Steam Market.
MIT License
160 stars 18 forks source link

KeyError: 'sessionid' #28

Closed henrydatei closed 1 year ago

henrydatei commented 1 year ago

I ran python3 market_arbitrage.py and I got the following error

Traceback (most recent call last):
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 526, in <module>
    main()
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 509, in main
    apply_workflow(
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 489, in apply_workflow
    creation_results, sale_results = create_then_sell_booster_packs_for_batch(
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 392, in create_then_sell_booster_packs_for_batch
    creation_results = create_booster_packs_for_batch(listing_hashes)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 351, in create_booster_packs_for_batch
    result = create_booster_pack(app_id=app_id)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 151, in create_booster_pack
    session_id = get_session_id(cookie=cookie)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 109, in get_session_id
    session_id = cookie['sessionid']
KeyError: 'sessionid'

Shortened console output:

Parsing the one-line javascript code displayed with the web browser.
Loading 11911 listings from disk.
[100/11600]
[200/11600]
...
[11400/11600]
[11500/11600]
Omitting dubious listing hash: 278360-#Economy_TradingCards_Type_GameType
Omitting dubious listing hash: 219740-#Economy_TradingCards_Type_GameType
Omitting dubious listing hash: 218620-#Economy_TradingCards_Type_GameType
Omitting dubious listing hash: 730-#Economy_TradingCards_Type_GameType
Omitting dubious listing hash: 464760-#Economy_TradingCards_Type_GameType
Omitting dubious listing hash: 209670-Cortex Command #Economy_TradingCards_ItemType_BoosterPack
Omitting dubious listing hash: 381210-Dead by Daylight #Economy_TradingCards_ItemType_BoosterPack
Omitting dubious listing hash: 570-Dota 2 #Economy_TradingCards_ItemType_BoosterPack
Omitting dubious listing hash: 279720-The I of the Dragon #Economy_TradingCards_ItemType_BoosterPack
Omitting dubious listing hash: 893180-#Economy_TradingCards_Type_GameType
There are 11901 seemingly valid market listings. (10 omitted because of a dubious listing hash)
No match found for Legend of Moros (appID = 449770)
#badges = 2264 ; #matching hashes found = 2264
Item type not found for 753-Sack of Gems
Listing: 753-Sack of Gems ; item id: 26463978 ; ask: 0.30€ (4002) ; bid: 0.28€ (12067)
A sack of 1000 gems can be bought for 0.30 €.
There are 756 booster packs with sell price unknown (217) or strictly higher than gem price (539).
There are 756 booster packs which can be immediately crafted. (0 excluded because of cooldown)
Loading 10700 listing details from disk.
Item type not found for 651340-Shephy Booster Pack
Item type not found for 1106750-Fault: Elder Orb Booster Pack
Item type not found for 252890-Dracula: Love Kills Booster Pack
Listing: 6370-Bloodline Champions Booster Pack ; item id: 33143882 ; ask: 0.85€ (2) ; bid: 0.24€ (3)
Listing: 32200-Metal Drift Booster Pack ; item id: 1884332 ; ask: -1.00€ (-1) ; bid: 0.21€ (20)
Listing: 33680-Eversion  Booster Pack ; item id: 1153329 ; ask: 0.40€ (11) ; bid: 0.35€ (17)
...
Listing: 1407200-World of Tanks Booster Pack ; item id: 176254794 ; ask: 0.17€ (1) ; bid: 0.13€ (17)
Listing: 1407420-Milo and the Magpies Booster Pack ; item id: 176281363 ; ask: 0.34€ (8) ; bid: 0.16€ (2)
Number of queries 50 reached. Cooldown: 70 seconds
Listing: 1548650-LudoNarraCon Supporter Pack featuring Cyrano Booster Pack ; item id: 176239981 ; ask: -1.00€ (-1) ; bid: 0.15€ (1)
Listing: 1575870-UpGun Booster Pack ; item id: 176300022 ; ask: 0.49€ (1) ; bid: 0.15€ (2)
Listing: 1604000-Milk outside a bag of milk outside a bag of milk Booster Pack ; item id: 176289144 ; ask: 0.19€ (7) ; bid: 0.15€ (17)
Listing: 1731270-Global City Booster Pack ; item id: 176280052 ; ask: 0.39€ (1) ; bid: 0.16€ (1)
Listing: 1755910-Capcom Arcade 2nd Stadium Booster Pack ; item id: 176323595 ; ask: 0.37€ (9) ; bid: 0.11€ (10)
0.01€   33680-Eversion  Booster Pack
0.02€   72850-The Elder Scrolls V: Skyrim Booster Pack
0.11€   206210-Gotham City Impostors: Free To Play Booster Pack
0.05€   212740-TERA Booster Pack
0.01€   227700-Firefall Booster Pack
0.12€   235340-Prime World Booster Pack
0.73€   243120-Betrayer Booster Pack
0.11€   264360-La Tale Booster Pack
1.89€   271290-HAWKEN Booster Pack
1.98€   298890-Adventure Time: The Secret Of The Nameless Kingdom Booster Pack
0.00€   305780-Echo of the Wilds Booster Pack
0.01€   327690-Gigantic Booster Pack
0.05€   336520-Might & Magic Heroes Online Booster Pack
0.03€   338180-Batla Booster Pack
0.31€   356050-Beyond Eyes Booster Pack
0.17€   356330-Dragomon Hunter Booster Pack
1.40€   369200-Ghost in the Shell: Stand Alone Complex - First Assault Online Booster Pack
0.06€   404770-SUPERFIGHT Booster Pack
0.04€   426970-Age of Magic CCG Booster Pack
0.41€   432150-They Came From The Moon Booster Pack
0.23€   451230-Wartune Booster Pack
0.68€   469830-Fable Fortune Booster Pack
0.01€   512200-Metal Carnage Booster Pack
0.01€   534500-Tiger Knight: Empire War Booster Pack
0.22€   536930-MOBIUS FINAL FANTASY Booster Pack
0.14€   556440-Vicious Circle Booster Pack
0.40€   560380-MapleStory 2 Booster Pack
3.69€   575550-Hell Girls Booster Pack
0.14€   588210-HELLION Booster Pack
0.16€   630100-SoulWorker Booster Pack
0.04€   719750-PUSS! Booster Pack
0.02€   728730-Holyday City: Reloaded Booster Pack
0.11€   795100-Friday the 13th: Killer Puzzle Booster Pack
0.01€   856880-Fighting Fantasy Classics Booster Pack
# Reminder of the gem price
A sack of 1000 gems can be bought for 0.30 €.
# Results after *slow* update of market order data for *many potential* arbitrages
*   Profit: 3.69€   575550-Hell Girls Booster Pack  | craft pack: 1000 gems (0.30€) | sell for 3.99€ (4.61€ incl. fee) (#=1)
*   Profit: 0.31€   356050-Beyond Eyes Booster Pack | craft pack: 857 gems (0.26€) | sell for 0.57€ (0.64€ incl. fee) (#=2)
*   Profit: 0.23€   451230-Wartune Booster Pack | craft pack: 667 gems (0.20€) | sell for 0.43€ (0.49€ incl. fee) (#=1)
*   Profit: 0.14€   556440-Vicious Circle Booster Pack  | craft pack: 750 gems (0.22€) | sell for 0.36€ (0.40€ incl. fee) (#=1)
*   Profit: 0.12€   235340-Prime World Booster Pack | craft pack: 750 gems (0.22€) | sell for 0.34€ (0.38€ incl. fee) (#=1)
*   Profit: 0.11€   795100-Friday the 13th: Killer Puzzle Booster Pack  | craft pack: 857 gems (0.26€) | sell for 0.37€ (0.41€ incl. fee) (#=4)
*   Profit: 0.11€   206210-Gotham City Impostors: Free To Play Booster Pack | craft pack: 1200 gems (0.36€) | sell for 0.47€ (0.53€ incl. fee) (#=1)
*   Profit: 0.06€   404770-SUPERFIGHT Booster Pack  | craft pack: 1000 gems (0.30€) | sell for 0.36€ (0.40€ incl. fee) (#=1)
*   Profit: 0.05€   336520-Might & Magic Heroes Online Booster Pack | craft pack: 857 gems (0.26€) | sell for 0.31€ (0.35€ incl. fee) (#=5)
*   Profit: 0.05€   212740-TERA Booster Pack    | craft pack: 750 gems (0.22€) | sell for 0.27€ (0.30€ incl. fee) (#=1)
*   Profit: 0.04€   719750-PUSS! Booster Pack   | craft pack: 667 gems (0.20€) | sell for 0.24€ (0.27€ incl. fee) (#=5)
*   Profit: 0.03€   338180-Batla Booster Pack   | craft pack: 1000 gems (0.30€) | sell for 0.33€ (0.37€ incl. fee) (#=1)
*   Profit: 0.02€   728730-Holyday City: Reloaded Booster Pack  | craft pack: 750 gems (0.22€) | sell for 0.24€ (0.27€ incl. fee) (#=1)
*   Profit: 0.01€   856880-Fighting Fantasy Classics Booster Pack   | craft pack: 750 gems (0.22€) | sell for 0.23€ (0.26€ incl. fee) (#=3)
Listing: 206210-Gotham City Impostors: Free To Play Booster Pack ; item id: 1795229 ; ask: -1.00€ (-1) ; bid: 0.53€ (1)
Listing: 212740-TERA Booster Pack ; item id: 175871119 ; ask: -1.00€ (-1) ; bid: 0.30€ (1)
Listing: 235340-Prime World Booster Pack ; item id: 1696307 ; ask: -1.00€ (-1) ; bid: 0.38€ (1)
Listing: 336520-Might & Magic Heroes Online Booster Pack ; item id: 81553936 ; ask: -1.00€ (-1) ; bid: 0.35€ (5)
Listing: 338180-Batla Booster Pack ; item id: 47727855 ; ask: -1.00€ (-1) ; bid: 0.37€ (1)
Listing: 356050-Beyond Eyes Booster Pack ; item id: 61941799 ; ask: -1.00€ (-1) ; bid: 0.64€ (2)
Listing: 404770-SUPERFIGHT Booster Pack ; item id: 162358782 ; ask: -1.00€ (-1) ; bid: 0.40€ (1)
Listing: 451230-Wartune Booster Pack ; item id: 165806799 ; ask: -1.00€ (-1) ; bid: 0.49€ (1)
Listing: 556440-Vicious Circle Booster Pack ; item id: 176080337 ; ask: -1.00€ (-1) ; bid: 0.40€ (1)
Listing: 575550-Hell Girls Booster Pack ; item id: 175865890 ; ask: -1.00€ (-1) ; bid: 4.61€ (1)
Listing: 719750-PUSS! Booster Pack ; item id: 176006423 ; ask: 0.38€ (3) ; bid: 0.27€ (5)
Listing: 728730-Holyday City: Reloaded Booster Pack ; item id: 175951654 ; ask: 0.39€ (18) ; bid: 0.27€ (1)
Listing: 795100-Friday the 13th: Killer Puzzle Booster Pack ; item id: 175980402 ; ask: 0.93€ (2) ; bid: 0.41€ (4)
Listing: 856880-Fighting Fantasy Classics Booster Pack ; item id: 175996971 ; ask: 0.39€ (17) ; bid: 0.26€ (3)
0.11€   206210-Gotham City Impostors: Free To Play Booster Pack
0.05€   212740-TERA Booster Pack
0.12€   235340-Prime World Booster Pack
0.05€   336520-Might & Magic Heroes Online Booster Pack
0.03€   338180-Batla Booster Pack
0.31€   356050-Beyond Eyes Booster Pack
0.06€   404770-SUPERFIGHT Booster Pack
0.23€   451230-Wartune Booster Pack
0.14€   556440-Vicious Circle Booster Pack
3.69€   575550-Hell Girls Booster Pack
0.04€   719750-PUSS! Booster Pack
0.02€   728730-Holyday City: Reloaded Booster Pack
0.11€   795100-Friday the 13th: Killer Puzzle Booster Pack
0.01€   856880-Fighting Fantasy Classics Booster Pack
Loading 10703 listing details from disk.
Item type not found for 206210-Gotham City Impostors: Free To Play Booster Pack
Item type not found for 338180-Batla Booster Pack
Item type not found for 451230-Wartune Booster Pack
Item type not found for 856880-Fighting Fantasy Classics Booster Pack
Item type not found for 235340-Prime World Booster Pack
Item type not found for 795100-Friday the 13th: Killer Puzzle Booster Pack
Item type not found for 404770-SUPERFIGHT Booster Pack
Item type not found for 728730-Holyday City: Reloaded Booster Pack
Item type not found for 356050-Beyond Eyes Booster Pack
Item type not found for 575550-Hell Girls Booster Pack
Item type not found for 556440-Vicious Circle Booster Pack
Item type not found for 212740-TERA Booster Pack
Item type not found for 336520-Might & Magic Heroes Online Booster Pack
Item type not found for 719750-PUSS! Booster Pack
# Results after *quick* update of market order data for *a few detected* arbitrages
*   Profit: 0.11€   795100-Friday the 13th: Killer Puzzle Booster Pack  | craft pack: 857 gems (0.26€) | sell for 0.37€ (0.41€ incl. fee) (#=4)
*   Profit: 0.04€   719750-PUSS! Booster Pack   | craft pack: 667 gems (0.20€) | sell for 0.24€ (0.27€ incl. fee) (#=5)
*   Profit: 0.02€   728730-Holyday City: Reloaded Booster Pack  | craft pack: 750 gems (0.22€) | sell for 0.24€ (0.27€ incl. fee) (#=1)
*   Profit: 0.01€   856880-Fighting Fantasy Classics Booster Pack   | craft pack: 750 gems (0.22€) | sell for 0.23€ (0.26€ incl. fee) (#=3)
{'795100-Friday the 13th: Killer Puzzle Booster Pack': 37.0, '719750-PUSS! Booster Pack': 24.0, '728730-Holyday City: Reloaded Booster Pack': 24.0, '856880-Fighting Fantasy Classics Booster Pack': 23.0}
Traceback (most recent call last):
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 526, in <module>
    main()
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 509, in main
    apply_workflow(
  File "/Users/henryhaustein/Downloads/steam-market/market_arbitrage.py", line 489, in apply_workflow
    creation_results, sale_results = create_then_sell_booster_packs_for_batch(
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 392, in create_then_sell_booster_packs_for_batch
    creation_results = create_booster_packs_for_batch(listing_hashes)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 351, in create_booster_packs_for_batch
    result = create_booster_pack(app_id=app_id)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 151, in create_booster_pack
    session_id = get_session_id(cookie=cookie)
  File "/Users/henryhaustein/Downloads/steam-market/inventory_utils.py", line 109, in get_session_id
    session_id = cookie['sessionid']
KeyError: 'sessionid'
woctezuma commented 1 year ago

The error arose when attempting to create booster packs, because the sessionid cookie could not be found.

To fix this issue, you need to fill in your cookies in personal_info.json, especially sessionid.

Once this is done, you could run the script again after toggling these boolean values to False to save time: https://github.com/woctezuma/steam-market/blob/57c717118fed8c660bd830f51f0ccfaf45fd5e40/market_arbitrage.py#L498-L499


That being said, I am surprised that the script could run this far without the cookies.

Did you fill in some of the info, but not all of the info, e.g. steamLoginSecure but not sessionid? 🤔 Indeed, if the sessionid cookie had been available but obsolete, then the error would have been different. Here, it seems that the value of the sessionid cookie was not filled in at all, but some of the rest of the cookies must have been correctly filled in, for the script to run this far.

henrydatei commented 1 year ago

I have done this. Literally 5 minutes before I ran the scriptVon meinem iPhone gesendetAm 19.01.2023 um 16:15 schrieb Wok @.***>: You need to fill in your cookies in personal_info.json.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

woctezuma commented 1 year ago

Interesting.

Then maybe the script updated the cookie values in the JSON file and erased the value of sessionid which you had previously filled in. Not sure how this would be possible. Edit: After looking at the code again, I don't think the dictionary entry for sessionid could be deleted when updating cookies.

Could you check which fields currently exist in the JSON file personal_info.json?

henrydatei commented 1 year ago
{
  "steamLoginSecure": "76561***"
}
henrydatei commented 1 year ago

Did you fill in some of the info, but not all of the info, e.g. steamLoginSecure but not sessionid? 🤔 Indeed, if the sessionid cookie had been available but obsolete, then the error would have been different. Here, it seems that the value of the sessionid cookie was not filled in at all, but some of the rest of the cookies must have been correctly filled in, for the script to run this far.

As you see above I didn't fill in the sessionid value because the README file just said I need the value for steamLoginSecure (or maybe I was just blind and didn't see it 😄 )

woctezuma commented 1 year ago

Did you fill in some of the info, but not all of the info, e.g. steamLoginSecure but not sessionid? 🤔 Indeed, if the sessionid cookie had been available but obsolete, then the error would have been different. Here, it seems that the value of the sessionid cookie was not filled in at all, but some of the rest of the cookies must have been correctly filled in, for the script to run this far.

As you see above I didn't fill in the sessionid value because the README file just said I need the value for steamLoginSecure (or maybe I was just blind and didn't see it 😄 )

Ah, I see where the confusion could come from.

Indeed, the README only mentions steamLoginSecure in the section called How to fill-in your cookie information. Based on the run of the script, this seems right: the script worked fine with relaxed rate-limits by solely using the steamLoginSecure cookie, and the script only failed at the very end when it was time to create booster packs.

The sessionid is mentioned a bit below in the README in an annotation (NB²) "to automate the creation and sale of booster packs". So I understand how it could be overlooked.

On a side-note, it is always possible to perform this last step (creation and sale of booster packs) manually by going to this page to create packs, and then manually listing packs on the Steam Market. This is especially relevant if there are only a few packs.