Having trouble creating JSON payload that contains (world of warcraft) races and the playable classes for each race

96 Views Asked by At

I'm using Python, sqlalchemy ORM, Flask, and oauth stuff. I'll try to specify this as much as possible...

I want to pull information from some online source (API, website, etc.) that will list out the playable races for World of Warcraft and then also have the playable classes for each race. I'm building an API for a final project in a college course and the Blizzard API only lists races and classes separately. It doesn't give me a good way to have the races and then the list of playable classes for each race.

Essentially, I want to be able to return a payload like the following:

"races": [
{
    "name": race.name,
    "faction": race.faction,
    "description": race.description,
    "link": url_for('race_info', raceName=race.name)
    "classes: ['warrior', 'paladin', 'hunter']
}
for race in races
]

I could just go through and add this stuff manually into my database, but my professor is insisting we pull info from the web and put it directly into our database. He doesn't want us to hardcode anything into our database.

Alternatively, if someone can think of a way for me to take the JSONs I'm receiving from Blizzard's API and somehow use that info to do what I want without just hardcoding everything, I'm open to ideas.

Sorry if I didn't specify my needs enough.

Edit: I was asked for samples of the races and classes JSON. If I print out the results from a request for /race and /class I get the following...

/race ... {'races': [{'description': 'test', 'faction': 'alliance', 'link': '/race/Human', 'name': 'Human'},... rest of races here

/class ... {'classes': [{'class name': 'Warrior', 'link': '/class/Warrior', 'power type': 'rage'},... rest of classes here

0

There are 0 best solutions below