Example using Postman ===================== .. toctree:: :hidden: In this example we first make a ``POST`` request, using Postman, to aquire a Bearer token and then we use the token to request statistics. Getting a token --------------- The information needed is all in open+ access. Go to the Configuration tab, select the customer and the select the API tab. Here you will find the ``client id`` and the ``client secret``. .. image:: ../Images/ConfigurationAPI.PNG Now we can go to Postman and make a request to the open+ Identity Server, which will return the token. 1. Create a new ``POST`` request to ``https://identity.opnbibliotheca.com/connect/token`` 2. Under Headers tab create key-value pair. .. code-block:: javascript Content-Type: application/x-www-form-urlencoded 3. Under Body tab create 4 key-value pairs. .. code-block:: javascript client_id : "your client id" client_secret : "your secret" grant_type : client_credentials scope : OpenPlusAPI 4. Now click Send to make the request and receive the token. .. image:: /Images/Token.PNG Now we can use the token to get statistics. Getting statistics ------------------ With the token it is now possible to make requests to the API. 1. Create a new ``GET`` request to ``https://api.opnbibliotheca.com/v1/peoplecount`` 2. Under the Authentication tab create a key-value pair. The value is "Bearer" + whitespace + the token. .. code-block:: javascript Authentication: Bearer "token" 3. Now click send to receive statistics. The statistics will look like below. .. image:: /Images/Statistics.PNG More queries ------------ Here are some example of queries. To get raw data: ``https://api.opnbibliotheca.com/v1/peoplecount`` To get aggregated data: ``https://api.opnbibliotheca.com/v1/peoplecount?aggregation=day`` To get paginated data: ``https://api.opnbibliotheca.com/v1/peoplecount?limit=5`` ```` **Pagination**. When using pagination or when result is larger than 1MB, you receive a startToken in the request. The startToken should be included in the next query to continue getting the next results and so on. It will look like this. ``https://api.opnbibliotheca.com/v1/peoplecount?limit=5`` The starttoken you receive should be included in the next query like this, where xxx is the starttoken you received in the previous query. ``https://api.opnbibliotheca.com/v1/peoplecount?limit=5&starttoken=xxx``