{% extends "base.html" %} {% load event_tags %} {% block content %}

{{ name }}


Your current API key is {{ key.key }}

Your current API Authorization Header value is ApiKey {{ user.username }}:{{ key.key }}

Has your key been exposed? Are you ready for a new one?

{% csrf_token %} {{ form.as_p }}

That's great, but how do I make calls to the API? Take a look at the API Documentation.

To use your API Key you need to specify an Authorization header. Example:

# As a header
# Format is ``Authorization: ApiKey <username>:<api_key>
Authorization: ApiKey {{ user.username }}:{{ key.key }}
	

Here is a simple python example against the /users endpoint

import requests

url = '{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.META.HTTP_HOST }}/api/v1/users'
headers = {'content-type': 'application/json',
		   'Authorization': 'ApiKey {{ user.username }}:{{ key.key }}'}
r = requests.get(url, headers=headers, verify=True) # set verify to False if ssl cert is self-signed

for key, value in r.__dict__.iteritems():
  print key
  print value
  print '------------------'
	
{% endblock %}