maximumstock / poe-currency-flip-planner

This tool is an attempt at planning short-term arbitrage deals of currency in Path of Exile.
MIT License
97 stars 19 forks source link

[Idea]: add an option to be able to pull assets from public stash tabs #285

Closed 1480c1 closed 3 years ago

1480c1 commented 4 years ago

It would be nice to be able to update the assets section with information from my public stash tabs, I have the code for running curl with my POESESSID and piping into jq to format the output into the same json format contained within the assets key, but I do not know how to convert that into python

maximumstock commented 3 years ago

Hey, sorry for the late answer. Would you mind sharing your curl setup, so I can use that as a basis?

Judging from the API docs, I think I have to get an actual API token in order to access the respective user's stashes to read that data. I'm not sure I want to get into this right now. Feel free to share if you have a idea on this or if this isn't relevant to you anymore.

1480c1 commented 3 years ago

Here's my bash script

#!/bin/bash

do_curl() {
    curl -Ls -H "Cookie: POESESSID=$POESESSID" "$@"
}

accountName=1480c1
league=Expedition

jq -r . > config/config.json << EOF
{
    "version": 1,
    "assets": $(
        stash=$(cat << 'FOE'
[
    .[].items |
    map_values({typeLine: .typeLine,stackSize: .stackSize}) |
    group_by(.typeLine) |
    foreach .[] as $item (
        0;
        if $item | length != 1 then
            [{typeLine: $item[].typeLine,stackSize: (reduce $item[].stackSize as $num (0; .+$num))}]
        else
            $item
        end
    ) | map({(.typeLine) : .stackSize}) | add
] | add | walk(
    if type=="object"
    then
        with_entries(select(.value|.==null or .==0|not))
    else
        .
    end
)
FOE
)
        for a in $(seq 0 $(($(do_curl "https://www.pathofexile.com/character-window/get-stash-items?league=$league&accountName=$accountName&tabs=0" | jq -r .numTabs) - 1)))
        do
            do_curl "https://www.pathofexile.com/character-window/get-stash-items?league=$league&accountName=$accountName&tabIndex=$a" | jq -c .
            sleep 1
        done | jq -cs "$stash"
    ),
    "trading": $(
        curl -Ls "https://www.pathofexile.com/api/trade/data/static" |
        jq -cs "$(
            cat << 'FOE'
[
    foreach (.[0].result[].entries | sort | .[].text) as $item (
        0;
        {
            ($item): { "sell_for": { "Chaos Orb": null, "Exalted Orb": null } }
        }
    )
]+[
    {
        "Chaos Orb": {
            "sell_for": [
                foreach (.[0].result[].entries | sort | .[].text) as $item (0; {($item): null})
            ] | add
        }
    }
] | add
FOE
        )"
    )
}
EOF

you would need to set POESESSID by getting it from your browser cookies from pathofexile.com (I used cookie quick manager on firefox https://github.com/ysard/cookie-quick-manager to get it) and replace accountName with your account and league as needed

1480c1 commented 3 years ago

This results in an asset section of

  "assets": {
    "Alchemy Shard": 16,
    "Alteration Shard": 11,
    "Armourer's Scrap": 205,
    "Blacksmith's Whetstone": 97,
    "Blessed Orb": 5,
    "Cartographer's Chisel": 100,
    "Chaos Orb": 22,
    "Chaos Shard": 7,
    "Chromatic Orb": 73,
    "Engineer's Orb": 7,
    "Engineer's Shard": 7,
    "Enkindling Orb": 6,
    "Exalted Orb": 2,
    "Gemcutter's Prism": 17,
    "Glassblower's Bauble": 41,
    "Harbinger's Shard": 5,
    "Horizon Shard": 4,
    "Instilling Orb": 8,
    "Jeweller's Orb": 195,
    "Orb of Alchemy": 33,
    "Orb of Alteration": 396,
    "Orb of Augmentation": 339,
    "Orb of Binding": 4,
    "Orb of Chance": 56,
    "Orb of Fusing": 1,
    "Orb of Horizons": 3,
    "Orb of Regret": 10,
    "Orb of Scouring": 22,
    "Orb of Transmutation": 463,
    "Perandus Coin": 2347,
    "Portal Scroll": 711,
    "Prime Sextant": 1,
    "Regal Orb": 4,
    "Scroll Fragment": 3,
    "Scroll of Wisdom": 899,
    "Silver Coin": 33,
    "Simple Sextant": 8,
    "Transmutation Shard": 2,
    "Vial of Fate": 1,
    "A Mother's Parting Gift": 1,
    "A Sea of Blue": 1,
    "Akil's Prophecy": 1,
    "Arrogance of the Vaal": 1,
    "Boon of Justice": 1,
    "Cursed Words": 1,
    "Dark Temptation": 1,
    "Death": 4,
    "Destined to Crumble": 2,
    "Doedre's Madness": 1,
    "Emperor's Luck": 2,
    "Gemcutter's Promise": 2,
    "Grave Knowledge": 2,
    "Her Mask": 3,
    "Humility": 2,
    "Jack in the Box": 1,
    "Lachrymal Necrosis": 1,
    "Lantador's Lost Love": 7,
    "Light and Truth": 2,
    "Loyalty": 4,
    "Lucky Connections": 1,
    "Lysah's Respite": 1,
    "Mitts": 2,
    "No Traces": 1,
    "Perfection": 1,
    "Prosperity": 1,
    "Rain Tempter": 1,
    "Rain of Chaos": 1,
    "Sambodhi's Wisdom": 1,
    "Scholar of the Seas": 1,
    "Shard of Fate": 2,
    "Struck by Lightning": 2,
    "The Admirer": 1,
    "The Battle Born": 5,
    "The Blazing Fire": 3,
    "The Calling": 2,
    "The Carrion Crow": 7,
    "The Catalyst": 2,
    "The Celestial Justicar": 1,
    "The Celestial Stone": 1,
    "The Chains that Bind": 1,
    "The Coming Storm": 1,
    "The Dark Mage": 3,
    "The Doppelganger": 2,
    "The Dreamland": 1,
    "The Feast": 1,
    "The Flora's Gift": 5,
    "The Fool": 1,
    "The Gambler": 4,
    "The Gemcutter": 2,
    "The Hale Heart": 1,
    "The Hermit": 2,
    "The Incantation": 6,
    "The Inoculated": 1,
    "The Inventor": 2,
    "The King's Blade": 9,
    "The Lover": 2,
    "The Lunaris Priestess": 6,
    "The Master Artisan": 2,
    "The Messenger": 1,
    "The Metalsmith's Gift": 8,
    "The Mountain": 1,
    "The Oath": 1,
    "The Opulent": 4,
    "The Pack Leader": 2,
    "The Patient": 1,
    "The Penitent": 1,
    "The Polymath": 1,
    "The Porcupine": 4,
    "The Primordial": 1,
    "The Puzzle": 1,
    "The Rabid Rhoa": 1,
    "The Realm": 1,
    "The Scarred Meadow": 2,
    "The Scavenger": 2,
    "The Scholar": 8,
    "The Sigil": 1,
    "The Skeleton": 1,
    "The Summoner": 1,
    "The Sun": 2,
    "The Surgeon": 3,
    "The Sword King's Salute": 1,
    "The Tinkerer's Table": 1,
    "The Twins": 1,
    "The Union": 3,
    "The Valley of Steel Boxes": 1,
    "The Warden": 2,
    "The Web": 1,
    "The Whiteout": 1,
    "The Witch": 1,
    "The Wolf's Shadow": 2,
    "The Wrath": 3,
    "Thirst for Knowledge": 1,
    "Three Voices": 2,
    "Thunderous Skies": 3,
    "Tranquillity": 2,
    "Treasure Hunter": 2,
    "Turn the Other Cheek": 3,
    "Underground Forest": 1,
    "Vanity": 1,
    "Vinia's Token": 1,
    "Volatile Power": 1,
    "Divine Vessel": 3,
    "Offering to the Goddess": 7,
    "Polished Bestiary Scarab": 1,
    "Rusted Breach Scarab": 1,
    "Rusted Elder Scarab": 1,
    "Sacrifice at Dawn": 15,
    "Sacrifice at Dusk": 15,
    "Sacrifice at Midnight": 1,
    "Sacrifice at Noon": 16,
    "Splinter of Esh": 15,
    "Splinter of Tul": 13,
    "Splinter of Xoph": 22,
    "Timeless Eternal Empire Splinter": 3,
    "Timeless Karui Splinter": 4,
    "Timeless Maraketh Splinter": 6,
    "Timeless Templar Splinter": 2,
    "Timeless Vaal Splinter": 6,
    "Muttering Essence of Anger": 1,
    "Muttering Essence of Contempt": 1,
    "Muttering Essence of Fear": 1,
    "Muttering Essence of Greed": 1,
    "Remnant of Corruption": 3,
    "Screaming Essence of Contempt": 1,
    "Screaming Essence of Envy": 1,
    "Screaming Essence of Fear": 1,
    "Screaming Essence of Greed": 2,
    "Screaming Essence of Hatred": 1,
    "Screaming Essence of Loathing": 2,
    "Screaming Essence of Misery": 1,
    "Screaming Essence of Rage": 1,
    "Screaming Essence of Sorrow": 2,
    "Screaming Essence of Spite": 1,
    "Screaming Essence of Suffering": 2,
    "Screaming Essence of Wrath": 1,
    "Screaming Essence of Zeal": 1,
    "Shrieking Essence of Contempt": 1,
    "Shrieking Essence of Doubt": 1,
    "Shrieking Essence of Hatred": 1,
    "Shrieking Essence of Rage": 1,
    "Shrieking Essence of Wrath": 1,
    "Wailing Essence of Anger": 1,
    "Wailing Essence of Anguish": 2,
    "Wailing Essence of Doubt": 1,
    "Wailing Essence of Fear": 2,
    "Wailing Essence of Greed": 2,
    "Wailing Essence of Hatred": 2,
    "Wailing Essence of Sorrow": 2,
    "Wailing Essence of Spite": 1,
    "Wailing Essence of Torment": 2,
    "Weeping Essence of Fear": 2,
    "Weeping Essence of Greed": 1,
    "Weeping Essence of Hatred": 1,
    "Weeping Essence of Rage": 1,
    "Weeping Essence of Sorrow": 1,
    "Weeping Essence of Suffering": 1,
    "Weeping Essence of Torment": 2,
    "Weeping Essence of Woe": 2,
    "Weeping Essence of Wrath": 1,
    "Whispering Essence of Contempt": 1,
    "Whispering Essence of Hatred": 2,
    "Whispering Essence of Woe": 2,
    "Abrasive Catalyst": 1,
    "Imbued Catalyst": 3,
    "Intrinsic Catalyst": 1,
    "Noxious Catalyst": 1,
    "Prismatic Catalyst": 1,
    "Tempering Catalyst": 1,
    "Turbulent Catalyst": 2,
    "Unstable Catalyst": 1,
    "Simulacrum Splinter": 15,
    "Amber Oil": 9,
    "Clear Oil": 5,
    "Sepia Oil": 5,
    "Verdant Oil": 2,
    "Aberrant Fossil": 2,
    "Dense Fossil": 2,
    "Frigid Fossil": 1,
    "Jagged Fossil": 2,
    "Metallic Fossil": 2,
    "Perfect Fossil": 1,
    "Pristine Fossil": 4,
    "Scorched Fossil": 6
  },

for my account specifically

maximumstock commented 3 years ago

Thank you for your input! I'm a bit swamped with work right now, but there is a WIP PR here.