Skip to content

An Example Client

Disclaimer

The client used throughout these pages serves as an example. The Python programming language has been chosen both for the its clarity and ubiquity. There are intentionally no library dependencies. If you are working with ${LANGUAGE} and need a client, you can use this example as a reference while consulting the complete JSON schemas.

Getting Started

Prerequisites

  1. You have a working installation of Python 3.
  2. You are familiar with the variables ARDOQ_API_HOST, ARDOQ_API_TOKEN and ARDOQ_ORL_LABEL described in the previous section.

Setup

  1. Create a new directory called ardoq_api_examples. It doesn't matter where where the directory is located.
  2. Download the Example Ardoq Client and place it in the directory. It should have the name example_ardoq_client.py.
  3. Create a new file called example.py and place it in the directory.

Testing the Client

In order to test the client and your credentials we can query the /api/v2/me endpoint. Modify the newly created example.py file to contain the following:

import example_ardoq_client
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--host", metavar="ARDOQ_API_HOST", type=str, help="host name")
parser.add_argument("--org", metavar="ARDOQ_ORG_LABEL", type=str, help="org label")
parser.add_argument("--token", metavar="ARDOQ_API_TOKEN", type=str, help="API Token")

if __name__ == "__main__":
    args = parser.parse_args()

    api = example_ardoq_client.API(
        ardoq_api_host=args.host, ardoq_org_label=args.org, ardoq_api_token=args.token
    )

    print(api.me())

Assuming that you have an API token 12345 that grants you access to myorg hosted on a custom domain myorg.ardoq.com:

python3 example.py --host https://myorg.ardoq.com --token XXXXXXXX

Should display something similar.

----------------------------------------------------
Using Ardoq host: https://myorg.ardoq.com
Using API token ending: ...XXXX
Using Org Label: <NOT PROVIDED>
----------------------------------------------------
{'org': {'label': 'myorg', 'name': 'My Org'}, 'user': {'email': 'me@myorg.com'}}

If you are not using a custom domain (ie your Ardoq instance is hosted on app.ardoq.com) then you could use the following

python3 example.py --org myorg --token XXXXXXXX
Which would display
----------------------------------------------------
Using Ardoq host: https://myorg.ardoq.com
Using API token ending: ...XXXX
Using Org Label: myorg
----------------------------------------------------
{'org': {'label': 'myorg', 'name': 'My Org'}, 'user': {'email': 'me@myorg.com'}}

Help

If you get an unexpected result please make sure that you have read the section about making a request.