Progress Report by Cosimo Leone
Collection of Pokemon
{
"resource_uri":"/api/v1/pokedex/1/",
"pokemon":[
{
"name":"wartortle",
"resource_uri":"api/v1/pokemon/8/"
},
{
"name":"blastoise",
"resource_uri":"api/v1/pokemon/9/"
},
{
"name":"caterpie",
"resource_uri":"api/v1/pokemon/10/"
},
{
"name":"metapod",
"resource_uri":"api/v1/pokemon/11/"
},
{
"name":"butterfree",
"resource_uri":"api/v1/pokemon/12/"
},
...]
}
All available Moves
{
"name":"Ice-punch",
"category":"",
"pp":15,
"description":
"Inflicts regular damage."
"Has a 10% chance to freeze the target.",
"power":75,
"created":"2013-11-03T15:06:09.503161",
"modified":"2013-12-24T15:24:29.687639",
"resource_uri":"/api/v1/move/8/",
"id":8,
"accuracy":100
}
Python Libraries Used
from __future__ import print_function
import os
import requests
import json
from pprint import pprint
if not os.path.exists("data/pokedex.json"):
f = open("data/pokedex.json", "w")
pokedex = requests.get("http://pokeapi.co/api/v1/pokedex/1/")
pokejson = pokedex.json()
with f as output_file:
json.dump(pokejson, output_file)
print("Called the API")
else:
print("Reading from file")
with open("data/pokedex.json") as data_file:
jdata = json.load(data_file)
pprint(jdata['pokemon'][0])
print("... and many more")