1. Home
  2. Developers
  3. Using the API in a third-party application

Using the API in a third-party application

PREREQUISITS

  • Create a The Keys account.
  • Contact us so that you can be set as a developer and have access to the documentation.
  • Access the documentation on https://api.the-keys.fr

API CALL EXAMPLE IN PYTHON

import requests 

import json 

import time 

import sys 

import logging 


try: 

   import http.client as http_client

except ImportError: 

   # Python 2 

   import httplib as http_client 

http_client.HTTPConnection.debuglevel = 1 


# You must initialize logging, otherwise you'll not see debug output. 

logging.basicConfig() 

logging.getLogger().setLevel(logging.DEBUG) 

requests_log = logging.getLogger("requests.packages.urllib3") 

requests_log.setLevel(logging.DEBUG) 

requests_log.propagate = True 



host = "api.the-keys.fr" 


#You need an authentification token to call the ws.

r = requests.post('https://%s/api/login_check'%host, data={"_username":sys.argv[1], "_password":sys.argv[2]}, verify=False) 

token = json.loads(r.text)["token"]

print(token) 


#Once you've got the token you can call all ws.

r = requests.get("https://%s/fr/api/v2/utilisateur/get/{userid}"%host, headers={"Authorization": "Bearer %s"%token}, verify=False)

print(r.text)