Skip to content

Instantly share code, notes, and snippets.

@andreagrandi
Created August 6, 2013 09:54
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 andreagrandi/6163253 to your computer and use it in GitHub Desktop.
Save andreagrandi/6163253 to your computer and use it in GitHub Desktop.
This is an example of an API call (a GET method) using the requests Python library.
import requests
from urllib import urlencode
api_base_url = 'http://localhost:8001/api/1/'
api_token = '******************************************'
auth_header = {'Authorization': 'Token ' + api_token}
parameters = [('type', 'adcountry'), ('limit', 1000)]
request = requests.get(api_base_url + 'facebook/search/', params = urlencode(parameters), headers = auth_header)
print request.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment