Introduction
Welcome to the Emissions Ecoinvent API documentation. This API provides access to comprehensive Life Cycle Impact Assessment (LCIA) data from the Ecoinvent database.
Base URL
Loading...
Response Format
All responses are returned in JSON format.
Authentication
All API requests require authentication using an API key. Include your API key in the x-api-key header.
curl -X GET ${API_BASE_URL}/ecoinvent/datasets \
-H "x-api-key: your_api_key_here"
const response = await fetch('${API_BASE_URL}/ecoinvent/datasets', {
headers: {
'x-api-key': 'your_api_key_here'
}
});
const data = await response.json();
import requests
response = requests.get(
'${API_BASE_URL}/ecoinvent/datasets',
headers={'x-api-key': 'your_api_key_here'}
)
data = response.json()
⚠️ Security Note
Never expose your API key in client-side code or public repositories. Keep it secure on your server.
Rate Limiting
API requests are limited per user based on their account settings. Default limits:
- Rate Limit: 100 requests
- Time Window: 60 seconds
Rate limit headers are included in each response:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1640000000
Pagination
List endpoints support pagination using query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page |
integer | 1 | Page number |
limit |
integer | 50 | Items per page (max: 100) |
sortBy |
string | id | Field to sort by |
sortOrder |
string | ASC | ASC or DESC |
Paginated Response Format
{
"data": [...],
"meta": {
"page": 1,
"limit": 50,
"total": 1000,
"totalPages": 20
}
}
Error Handling
The API implements comprehensive error handling with detailed error responses to help you quickly identify and resolve issues.
✨ Enhanced Error Handling
All API errors include detailed context including timestamps, request path, HTTP method, and descriptive messages.
HTTP Status Codes
| Status Code | Description | When It Occurs |
|---|---|---|
200 |
Success | Request completed successfully |
201 |
Created | Resource created successfully |
400 |
Bad Request | Invalid input, missing required parameters, or validation errors |
401 |
Unauthorized | Missing or invalid API key |
403 |
Forbidden | Insufficient permissions for the requested resource |
404 |
Not Found | Requested resource does not exist |
429 |
Too Many Requests | Rate limit exceeded |
500 |
Internal Server Error | Server-side error or database error |
Error Response Format
All error responses follow a consistent format with the following fields:
{
"statusCode": 404,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/ecoinvent/activities/invalid-uuid",
"method": "GET",
"error": "Not Found",
"message": "Activity not found with UUID: invalid-uuid"
}
Error Response Fields
| Field | Type | Description |
|---|---|---|
statusCode |
number | HTTP status code |
timestamp |
string | ISO 8601 timestamp when the error occurred |
path |
string | The API endpoint that was requested |
method |
string | HTTP method used (GET, POST, etc.) |
error |
string | Error type or category |
message |
string | string[] | Detailed error message(s) explaining what went wrong |
Common Error Examples
400 Bad Request - Missing Required Parameter
{
"statusCode": 400,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/ecoinvent/activities/:uuid",
"method": "GET",
"error": "Bad Request",
"message": "Activity UUID is required"
}
400 Bad Request - Invalid Input Validation
{
"statusCode": 400,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/logs",
"method": "GET",
"error": "Bad Request",
"message": "Limit must be a number between 1 and 1000"
}
404 Not Found - Resource Not Found
{
"statusCode": 404,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/ecoinvent/datasets/non-existent-id",
"method": "GET",
"error": "Not Found",
"message": "Dataset not found with ID: non-existent-id"
}
401 Unauthorized - Invalid API Key
{
"statusCode": 401,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/ecoinvent/datasets",
"method": "GET",
"error": "Unauthorized",
"message": "Invalid API key"
}
500 Internal Server Error - Database Error
{
"statusCode": 500,
"timestamp": "2025-12-29T10:30:45.123Z",
"path": "/ecoinvent/emissions/search",
"method": "GET",
"error": "Internal Server Error",
"message": "Database error while searching emissions"
}
Input Validation
The API performs comprehensive input validation on all requests:
- Required Parameters: All required path and query parameters are validated
- Data Types: Parameters are type-checked and automatically converted when possible
- Range Validation: Numeric parameters (e.g., page, limit) are validated against min/max values
- Format Validation: UUIDs, dates, and other formatted values are validated
- Empty Values: Empty strings and null values are rejected for required fields
Error Logging
All errors are automatically logged on the server with:
- Full error stack traces for debugging
- Request context (path, method, user)
- Timestamp and error severity
- Database connection status
⚠️ Error Handling Best Practices
- Always check the
statusCodefield in responses - Use the
messagefield to display user-friendly error messages - Implement retry logic for 500-level errors
- Respect rate limits to avoid 429 errors
- Validate input on the client side before making requests