Last updated: 2023-11-22
URL
The Faradai Sustain API is accessible at:
The API expects GET and POST requests. For POST requests, a valid JSON string in the request body is expected. All responses are in JSON format.
All request must contain the following headers:
Content-Type: application/json
Authorization: Bearer <token>
Endpoints
1- Authorize
Returns an access token if the provided arguments (email and password) are correct.
Request:
Method | URL |
---|---|
POST | /authorize |
JSON parameters:
Param | Value | Description |
---|---|---|
email* | string | User email address |
password* | string | User password |
Response:
Field | Type | Description |
---|---|---|
token | string | Use this token for making requests in the Authorization header like: Bearer eyJhbG… |
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyQ2xhaW1zIjp7ImV..."
}
2- Get Data
Returns emissions data for the locations visible to the user.
Request:
Method | URL |
---|---|
GET | /data |
Query Params:
Param | Value | Description | Example |
---|---|---|---|
start | string | Start date | 2023-01-01 |
end | string | End date | 2023-06-30 |
Example:
GET /data?start=2023-01-01&end=2023-06-30 |
---|
Response:
Field | Type | Description |
---|---|---|
date range | object | Date range of the response data |
locations | array | Emissions data |
Locations have the following properties:
Field | Type | Description |
---|---|---|
name | string | Location name |
country | string | Location country |
sector | string | Location sector |
sources | array | Location's source list |
Sources have the following properties:
Field | Type | Description |
---|---|---|
name | string | Source name |
sourceType | string | Source type (electricity etc.) |
sourceTypeGroup | string | Source type group (default etc.) |
consumptionUnit | string | Source unit (kWh,MWh etc.) |
emissionUnit | string | Source emission unit if it has an emission factor value |
data | array | List of data to be retrieved |
Data have the following properties:
Field | Type | Description |
---|---|---|
date | string | Date range of the data |
source fields | int, string | Source fields and values |
emission | integer | Source emission if it has an emission factor value |
{
"date-range": [
"2022-12-31T21:00:00.000Z",
"2023-01-08T20:59:59.999Z"
],
"locations": [
{
"name": "Example Building",
"country": "United States of America",
"sector": "Commercial Services & Supplies",
"sources": [
{
"name": "FirstSource",
"sourceType": "electricity",
"sourceTypeGroup": "default",
"consumptionUnit": "kWh",
"emissionUnit": "CO2e",
"data": [
{
"date": [
"2023-01-01",
"2023-01-07"
],
"consumption": 50,
"cost": 60,
"emission": 15,
"customField": 5
}
]
},
{
"name": "SecondSource",
"sourceType": "electricity",
"sourceTypeGroup": "default",
"consumptionUnit": "kWh",
"emissionUnit": "CO2e",
"data": [
{
"date": [
"2023-01-01",
"2023-01-07"
],
"consumption": 50,
"cost": 60,
"emission": 5,
"customField": "text"
}
]
}
]
}
]
}