Skip to content

Instantly share code, notes, and snippets.

@mosampaio
Last active August 23, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosampaio/0c117c571c7351a3fbfa6be88d806ef9 to your computer and use it in GitHub Desktop.
Save mosampaio/0c117c571c7351a3fbfa6be88d806ef9 to your computer and use it in GitHub Desktop.
How to consume a json Rest API with Python using http.client
import http.client
conn = http.client.HTTPSConnection("api.github.com")
conn.request(method="GET", url="/repos/twilio/twilio-python/contributors",
headers={'user-agent': 'My App'})
r1 = conn.getresponse()
data1 = r1.read()
print(data1)
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment