How to get fortnite stats in python

Viewed 286

So i was trying to find something to code, and i decided to use python to get fortnite stats, i came across the fortnite_python library and it works, but it displays item codes for items in the shop when i want it to display the names. Anyone know how to convert them or just disply the name in the first place? This is my code.

​
fortnite = Fortnite('c954ed23-756d-4843-8f99-cfe850d2ed0c')
store = fortnite.store()
fortnite.store()


It outputs something like this 
[<StoreItem 12511>,
2 Answers

To print out the attributes of a Python object you can use __dict__ e.g.

from fortnite_python import Fortnite
from json import dumps

fortnite = Fortnite('Your API Key')
# ninjas_account_id = fortnite.player('ninja')
# print(f'ninjas_account: {ninjas_account_id}') # ninjas_account: 4735ce91-3292-4caf-8a5b-17789b40f79c

store = fortnite.store()
example_store_item = store[0]
print(dumps(example_store_item.__dict__, indent=2))

Output:

{
  "_data": {
    "imageUrl": "https://trackercdn.com/legacycdn/fortnite/237112511_large.png",
    "manifestId": 12511,
    "name": "Dragacorn",
    "rarity": "marvel",
    "storeCategory": "BRSpecialFeatured",
    "vBucks": 0
  },
  "id": 12511,
  "image_url": "https://trackercdn.com/legacycdn/fortnite/237112511_large.png",
  "name": "Dragacorn",
  "rarity": "marvel",
  "store_category": "BRSpecialFeatured",
  "v_bucks": 0
}

So it looks like you want to use name attribute of StoreItem:

for store_item in store:
    print(store_item.name)

Output:

Dragacorn
Hulk Smashers
Domino
Unstoppable Force
Scootin'
Captain America
Cable
Probability Dagger
Chimichanga!
Daywalker's Kata
Psi-blade
Snap
Psylocke
Psi-Rider
The Devil's Wings
Daredevil
Meaty Mallets
Silver Surfer
Dayflier
Silver Surfer's Surfboard
Ravenpool
Silver Surfer Pickaxe
Grand Salute
Cuddlepool
Blade
Daredevil's Billy Clubs
Mecha Team
Tricera Ops
Combo Cleaver
Mecha Team Leader
Dino
Triassic
Rex
Cap Kick
Skully
Gold Digger
Windmill Floss
Bold Stance
Jungle Scout

It seems that the library doesn't contain a function to get the names. Also this is what the class of a item from the store looks like:

class StoreItem(Domain):
    """Object containing store items attributes"""

and thats it.

Related