General
Example usage¶
Here are some examples of what APIs your app might want to use:
- Authenticate all your following API requests with the API token.
- Retrieve visitor statistics for room
- Retrieve treatment reports for room
Authentication and Authorization¶
You need to authenticate using API tokens when using reporting APIs. For info on how to get and use API token see Authentication topic of Giosg HTTP API.
Success
NOTE! Only users with 'reports' permission are allowed to get access to reporting services.
Authentication with an API token¶
1 2 |
|
To authenticate to reporting service you need to provide the api_key
for each following API request in a Authorization
HTTP header:
Authorization: Token <api_key>
You should replace the <api_key>
with the token you created.
Accept Header¶
You also need to define that you accept JSON-formatted responses by providing the Accept HTTP header:
Accept: application/json
Alternatively, if you are unable to customize headers, you may add format=json
GET parameter.
Time ranges¶
Unless stated otherwise, all the endpoints that require time range to be specified allow maximum range of 180 days.
Time ranges are inclusive meaning that both end and start date are included in
results. For example if you specify 2016-01-01
as a start_date
and 2016-01-02
as end_date
you will get report data from two days.
Migrating from reporting.giosg.com to api.giosg.com¶
Success
NOTE! If you are still using APIs from reporting.giosg.com you should read this
Our old reporting domain reporting.giosg.com has been deprecated and will be removed in the future. It is being replaced with our new API Gateway at api.giosg.com
Here is how you can migrate your existing code from reporting.giosg.com to api.giosg.com
Previous workflow¶
- Create an API Token from the web interface if you do not have on already
- Example API token
03d90e5dbba495469af27ab32dd27cee461a26bc
- Use the API token to fetch permission token from Reporting Permission API
- Example request
POST https://service.giosg.com/api/v5/orgs/9ae65e7d-56c5-11e5-af8d-6c4008c08dfe/rooms/b0a1d32b-e82c-11e4-b081-6c4008adf7e8/permissions/reporting
- Permission API responds with a permission token that expires in 10 minutes
- Use that permission token to fetch data from reporting APIs
Because api.giosg.com now handles permissions and authentication using reporting APIs is simplified.
Permission tokens are not needed anymore. You can just create your API Token and start fetching data.
New workflow¶
- Create an API Token from the web interface if you do not have on already
- Use the API token to fetch data from from reporting APIs