Data Connector Guide & API Documentation
Getting Started
Generating Your API Token
- Navigate to the Data Connector section in your settings.
- Click the "Generate New Token" button.
- Copy the generated token using the "Copy Token" button.
Using Your API Token
Include the API token in the header of your API requests:
http
Authorization: Bearer YOUR_API_TOKEN
Ensure you use HTTPS for all API calls to protect your token. Successful requests will return a status code of 200 OK.
Revoking and Regenerating Tokens
If you believe your token has been compromised, navigate back to the Data Connector section.
- Click "Generate New Token" to revoke the current token and generate a new one or disable the use of the token.
- Update your applications with the new token.
Rate Limiting
The API allows up to 20 requests per minute; 200 requests per hour, and 1000 requests per day. If you exceed this limit, you will receive a 429 Too Many Requests error. Wait a minute before making further requests.
Best Practices for Security
- Never share your API token publicly.
- Store your API token in a secure location, such as environment variables or a secrets manager.
- Regularly rotate your API token for enhanced security.
Troubleshooting Common Issues
- Invalid Token: Ensure that the token is correctly copied and included in the request header.
- Token Expired: Regenerate your token if it has expired.
Request Endpoint - Waste logs
GET https://web.positivecarbon.com/api/positive_carbon_waste_logs
Headers & Metadata:
YOUR_API_TOKENtotalItems: the total count of waste log eventscurrentPage: the current page of items - used to iterate through pages of itemstotalPages: the number of pages to iterate throughpageSize: the number of waste log events / items returned on the current page. Default = 100, requests are limited to 100 items per page.
Fields Returned:
| Field | Description |
|---|---|
| Site name | The name of the site |
| Client Site ID | The client’s ID of the site (if given and uploaded to the Positive Carbon system) |
| Timestamp | The timestamp of the wasted food log, when it occurred |
| Device / Monitor name | The monitor/area of waste monitoring within the site. There may be only one camera and one monitor. |
| Food | The identified food item in the waste log |
| Food Category | The category that the food item belongs to |
| Food Subcategory | The subcategory that the food item belongs to |
| Trimmings flag | An indicator to flag whether the wasted food item was trimmings |
| Weight (KG) | The weight of the wasted food in kg |
| Cost of Waste (EUR) | The calculated euro amount of the wasted food event |
| Waste Emissions (CO2eq) | The calculated carbon equivalent of the wasted food event in kg |
| Water footprint | The calculated water impact of the wasted food event in litres |
| Most Recent Comment | The most recent comment of a user on the Positive Carbon Image Feed page |