Setting Up the APIKey for Standard Login

You can use the Admin API through standard username/password session setup (Example 1), or through the Arcadia APIKey system (Example 2). In the second approach, the client code must obtain the ArcViz access key through a client-controlled mechanism.

Subsequently, request headers include this key as the access credential, avoiding the login process (Example 3).

Example 1: Establishing a session with username/password login

username = (user name as obtained from external source)
password = (password as obtained from external source)

session = requests.session()
response = session.get(login_url)
session.headers['referer'] = response.url
payload = {'username':username,
           'password':password,
           'csrfmiddlewaretoken':session.cookies['arccsrftoken']}
session.post(login_url, data=payload)

Example 2: Adding the APIKey to request header

apikey = (apikey string as obtained from external source)

session = requests.session()
session.headers['AUTHORIZATION'] = 'apikey %s' % apikey

Example 3: Fetching data on all datasets in the system

response = session.get(api_url + 'datasets?detail=1')
datasets = response.json()