Skip to main content

Data Connector Guide & API Documentation

Getting Started

Generating Your API Token

  1. Navigate to the Data Connector section in your settings.
  2. Click the "Generate New Token" button.
  3. 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_TOKEN
  • totalItems: the total count of waste log events
  • currentPage: the current page of items - used to iterate through pages of items
  • totalPages: the number of pages to iterate through
  • pageSize: the number of waste log events / items returned on the current page. Default = 100, requests are limited to 100 items per page.

Fields Returned:

FieldDescription
Site nameThe name of the site
Client Site IDThe client’s ID of the site (if given and uploaded to the Positive Carbon system)
TimestampThe timestamp of the wasted food log, when it occurred
Device / Monitor nameThe monitor/area of waste monitoring within the site. There may be only one camera and one monitor.
FoodThe identified food item in the waste log
Food CategoryThe category that the food item belongs to
Food SubcategoryThe subcategory that the food item belongs to
Trimmings flagAn 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 footprintThe calculated water impact of the wasted food event in litres
Most Recent CommentThe most recent comment of a user on the Positive Carbon Image Feed page