Add API documentation to GUIDE.md

This commit is contained in:
Paweł Jastrzębski 2022-01-05 10:27:14 +01:00
parent ba91ed561d
commit 6d84f63130

View File

@ -208,6 +208,25 @@ In a single-page application, the page never reloads. (That's the entire point o
Fortunately, Shynet offers a simple method you can call from anywhere within your JavaScript to indicate that a new page has been loaded: `Shynet.newPageLoad()`. Add this method call to the code that handles routing in your app, and you'll be ready to go.
### API
All data displayed on dashboard can be obtained via API on url ```//shynet.example.com/api/dashboard/```.
By default this url return full data from all services from last 30 days.
Authentication header should be set to use user's parsonal API token (```'Authorization:Token <user API token>'```).
There are 4 optional query parameters:
* uuid - to get data only from one service
* startDate - to set start date in format YYYY-MM-DD
* endDate - to set end date in format YYYY-MM-DD
* basic - to get only basic data set to '1' or 'true'
Example in HTTPie:
```http get '//shynet.example.com/api/dashboard/?uuid={{service_uuid}}&startDate=2021-01-01&endDate=2050-01-01&basic=1' 'Authorization:Token {{user_api_token}}'```
Example in cURL:
```curl -H 'Authorization:Token {{user_api_token}}' '//shynet.example.com/api/dashboard/?uuid={{service_uuid}}&startDate=2021-01-01&endDate=2050-01-01&basic=1'```
---
## Troubleshooting