I've got an API key. What happens now?

Accessing our API is easy, free and available to all.

Once you start using it, you will like it so much that you may hit our rate limit. If that happens, do not despair. Email us and ask for an API key. It will consist of an <app_name> and a <secret> combination.

So you've got the key, what happens now?

  • Request a token with your credentials using the method /public/auth/request_token
import requests  
API='https://www.targetvalidation.org/api/latest/'

jwt = requests.get(API + 'public/auth/request_token',  
                     params={'app_name':<appname>,'secret':<secret>})

print(jwt.json())  
  • Check the token is valid:
is_valid = requests.get(API +'public/auth/validate_token',  
                        headers={'Auth-Token': jwt.json()['token']})
print(is_valid.text)  
  • Read the token served in the response and pass it into any other following request as an Auth-Token header
import requests  
from pprint import pprint

def get_token(app_name,secret):  
    jwt = requests.get(API + 'public/auth/request_token',
                     params={'app_name':app_name,'secret':secret})
    return jwt.json()['token']

token =    get_token(<appname>,<secret>)

response = requests.get(API + 'association/filter',  
                        params={'disease'='EFO_0000270'},
                        headers={'Auth-Token': token})

pprint(response.json())
  • When your token expires, you will get a 419 error. If it happens, please request another token.
if response.status_code == 419:  
    # get a new token and try again
    token = get_token()
    r =    requests.get( ...
else:  
    # go ahead
    dosomething(response.json()['data'] ...

Keep in mind that getting a new token for each request is not recommended. This will impact your usage limit and slow down all other calls.

Other than that, go look at our API, request the key if necessary and share the news.