Step 1: Create a Site
Now that you have your credentials, let’s create your first site through our API. If you prefer to create your sites manually, you can also do so in our portal
Creating a Site
The first step is to set up a minimal "empty" site. You can expand the configuration later as needed. This initial request establishes a new site and returns the MQTT connection details to send measurement and transaction data to.
Request Parameters
site_id(string): A unique identifier for the site, used as part of the MQTT topic.name(string): A descriptive name for the site.country(string): The ISO-3166 country code of the country in which the site is situatedlocation(object): An object describing the site's location:name(string): A descriptive name of the location.coordinates(array): The site's geographic coordinates, represented as[longitude, latitude, altitude]. Note: if you don't know the altitude, just fill in 0.
- cURL
- Python
- JavaScript
curl -X POST "https://api.pleevi.ai/v1/sites/" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
-d '{
"site_id": "<YOUR_SITE_ID>",
"name": "<YOUR_SITE_NAME>",
"country": "<ISO_COUNTRY_CODE>",
"location": {
"name": "<LOCATION_NAME>",
"coordinates": [lat, long, alt]
}
}'
import requests
url = "https://api.pleevi.ai/v1/sites/"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer <YOUR_ACCESS_TOKEN>",
}
data = {
"site_id": "<YOUR_SITE_ID>",
"name": "<YOUR_SITE_NAME>",
"country": "<ISO_COUNTRY_CODE>",
"location": {
"name": "<LOCATION_NAME>",
"coordinates": [lat, long, alt]
}
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
print("Site created successfully:", response.json())
else:
print("Error:", response.status_code, response.text)
const axios = require("axios");
const url = "https://api.pleevi.ai/v1/sites/";
const data = {
site_id: "<YOUR_SITE_ID>",
name: "<YOUR_SITE_NAME>",
country: "<ISO_COUNTRY_CODE>",
location: {
name: "<LOCATION_NAME>",
coordinates: [lat, long, alt],
},
};
axios
.post(url, data, {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer <YOUR_ACCESS_TOKEN>`,
},
})
.then((response) => console.log("Site created successfully:", response.data))
.catch((error) =>
console.error("Error:", error.response?.data || error.message)
);
Response
A successful request returns the created site details, including the MQTT topic for sending measurement and transaction data. Take note of this MQTT topic as you will need it in the next step.
{
"_id": "67ec17cdfa5ac21ed7c50bd2",
"site_id": "<YOUR_SITE_ID>",
"name": "<YOUR_SITE_NAME>",
"country": "<ISO_COUNTRY_CODE>",
"location": {
"name": "<LOCATION_NAME>",
"coordinates": [lat, long, alt]
},
...
"connections": {
"mqtt": {
"cluster": "mqtt.pleevi.ai",
"energy_measurement_topic": "prd/v2/<YOUR_PARTNER_ID>/<YOUR_SITE_ID>/asset/<asset_id>/energyMeasurement",
"transaction_topic": "prd/v2/<YOUR_PARTNER_ID>/<YOUR_SITE_ID>/asset/<asset_id>/transaction",
"advice_topic": "prd/v2/<YOUR_PARTNER_ID>/<YOUR_SITE_ID>/asset/<asset_id>/advice",
"notification_topic": "prd/v2/<YOUR_PARTNER_ID>/<YOUR_SITE_ID>/notification/<event_name>"
}
}
}
Need Help?
If you encounter any issues, feel free to reach out to our support team at support@pleevi.ai.