Skip to content

Instantly share code, notes, and snippets.

View copley's full-sized avatar

Max Copley. SWEN Graduate from VUW (Wellington, NZ) copley

View GitHub Profile
@khoubyari
khoubyari / python-rest-json
Last active August 5, 2017 04:09
Python: Call REST API and access the JSON results (no authentication)
# tested with Python 2.7.5
import json
import urllib2
api_url = "http://jsonplaceholder.typicode.com/users"
# API below returns an array of complex JSON objects
jsonobj = json.load(urllib2.urlopen(api_url))
# index into the array and access a sub-attribute like this: