Sites API
Sites API provides HTTP API to handle sites' objects.
Create Site
POST /sites
Creates a new site with provided parameters and returns created site object.
This API is not available on Gateway
Request
$ curl -X POST \
http://api.enapter.com/v3/sites \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"name": "Test Site",
"timezone": "UTC"
}'
Body Parameters
namestringrequired#Name for the new site.
timezonestringrequired#Timezone for the new site.
location.namestring#Location name for the new site.
location.latitudestring#Location latitude for the new site.
location.longitudestring#Location longitude for the new site.
Response
Information about created site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
site.idstring#ID of the site.
site.namestring#Name of the site.
site.timezonestring#Timezone of the site.
site.location.namestring#Location name of the site.
site.location.latitudestring#Location latitude of the site.
site.location.longitudestring#Location longitude of the site.
site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
site.versionstring#Version of the site. Should be always
V3at now.
Get Site
GET /sites/{site_id}
Returns information about site with site_id.
Gateway has a single site and it has a shortcut API GET /site.
Request
$ curl http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b
Response
Retrieved site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
site.idstring#ID of the site.
site.namestring#Name of the site.
site.timezonestring#Timezone of the site.
site.location.namestring#Location name of the site.
site.location.latitudestring#Location latitude of the site.
site.location.longitudestring#Location longitude of the site.
site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
site.versionstring#Version of the site. Should be always
V3at now.
Update Site
PATCH /sites/{site_id}
Updates site information. You should be an OWNER at least to do this.
Gateway has a single site and it has a shortcut API PATCH /site.
Request
$ curl -X PATCH \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"timezone": "Europe/Berlin",
"location": {
"latitude": 52.520008,
"longitude": 13.404954
}'
It is also possible to reset some fields:
$ curl -X PATCH \
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"timezone": "Europe/Berlin",
"_reset" ["location.name"]
}'
Body Parameters
namestring#The new name for the site.
timezonestring#The new timezone for the site.
location.namestring#The new location name for the site.
location.latitudestring#The new location latitude for the site.
location.longitudestring#The new location longitude for the site.
_resetarray of strings#The list of fields to reset. Available values:
location.name, location.latitude, location.longitude.
Response
Updated site:
{
"site": {
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "Europe/Berlin",
"version": "V3",
"authorized_role": "INSTALLER"
}
}
site.idstring#ID of the site.
site.namestring#Name of the site.
site.timezonestring#Timezone of the site.
site.location.namestring#Location name of the site.
site.location.latitudestring#Location latitude of the site.
site.location.longitudestring#Location longitude of the site.
site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
site.versionstring#Version of the site. Should be always
V3at now.
List Sites
GET /sites
Returns all sites available to the user.
It does not make any sense to get sites list on Gateway, because it has only single site. It simpler to get this single site via GET /site.
Request
$ curl http://api.enapter.com/v3/sites
Query Parameters
limitnumber#The maximum number of sites to return.
offsetnumber#The number of sites to skip. Sites ordered by ID.
name.containsstring#Filter sites by name.
Response
List of sites:
{
"sites": [{
"id": "fecbbba0-79f2-4e9e-a6f0-69a310ab110b",
"name": "Test Site",
"timezone": "UTC",
"version": "V3",
"authorized_role": "INSTALLER"
},{
"id": "69a3110b-6ff2-fba0-a079-4eecbb9e0ab1",
"name": "Our Factory",
"timezone": "Europe/Berlin",
"version": "V3",
"authorized_role": "USER",
"location": {
"name: "Berlin",
"latitude": 52.520008,
"longitude": 13.404954
}
}]
}
Each site object has the following fields:
site.idstring#ID of the site.
site.namestring#Name of the site.
site.timezonestring#Timezone of the site.
site.location.namestring#Location name of the site.
site.location.latitudestring#Location latitude of the site.
site.location.longitudestring#Location longitude of the site.
site.authorized_rolestring#User authorized role for the site. See authorization system for more details.
site.versionstring#Version of the site. Should be always
V3at now.
Delete Site
DELETE /sites
Deletes site. You should be an OWNER at least to do this.
It's not possible to delete site on Gateway, because it has a single site.
Request
$ curl -X DELETE
http://api.enapter.com/v3/sites/fecbbba0-79f2-4e9e-a6f0-69a310ab110b