Skip to content

Instantly share code, notes, and snippets.

@horeaporutiu
Created January 4, 2019 21:23
Show Gist options
  • Save horeaporutiu/0009ddbd9c990ecbb4cd918decbdec79 to your computer and use it in GitHub Desktop.
Save horeaporutiu/0009ddbd9c990ecbb4cd918decbdec79 to your computer and use it in GitHub Desktop.
make your first api call in python
# this is the module that helps us make API calls (requests)
import requests
# this module helps us print all aspects of the data returned from API call
from pprint import pprint
# to make a different API call, just change the url below to a API endpoint. Two examples, one pokemon, one for longitude and latitude
# response = requests.get("http://api.open-notify.org/iss-now.json")
response = requests.get("https://pokeapi.co/api/v2/pokemon/ditto")
pprint(vars(response))
@horeaporutiu
Copy link
Author

horeaporutiu commented Jan 4, 2019

  1. Make sure you have Python installed on your computer
  2. in Terminal application, create a file called introToAPI.py and copy and paste this code into that file
  3. in Terminal, go to the same folder where this file is, and then run the following command

python ./introToAPI.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment