The Admin API supports two alternatives for setting up a session: Standard Login Access and APIKey Access. After establishing access, you can proceed to Fetching Data from All Datasets in the System.
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)
Note
that the login URL has the form
[http|https]:/host:port/arc/apps/login
.
For syntax of other parameters, see Admin API Syntax Parameters.
To establish a session through the Arcadia APIKey system (see Creating New API Keys) and avoid the login process, use the following code:
apikey = (apikey string)
session = requests.session()
session.headers['AUTHORIZATION'] = 'apikey %s' % apikey
In
this approach, the client code must obtain the ArcViz access key through a
client-controlled mechanism, then add the APIKey to the request header and
avoid explicit login.After setting up a session, you can fetch entire data from all datasets in the system, by using the following code:
response = session.get(api_url + 'datasets?detail=1')
datasets = response.json()
Note that the API URL has the form
[http|htttps]://host:port/arc/adminapi/version
.
Use the URL option 'detail=true
' to fetch all
information in the GET
call.