Server API v2
Server API v2
All requests need to be encoded in JSON format using UTF-8 character set (appropriate HTTP header
needs to be set – Content-type: application/json; charset=utf-8). The server responds with
JSON responses.
Authentication
For the purpose of accessing server API a new user role was created. This role is called Service. All users
of this role can access the server API, but they are not allowed to login into UI. No other user role will be
allowed to access the server API. All requests authenticated with a user in a role other than Service will
fail with HTTP status code 402 Forbidden.
All requests must be authenticated and authorized. To authenticate a request the user credentials needs
to be provided. There are two ways how to provide it:
The string after Basic (in red) is Base64 encoded text in form of <user>:<password>
For this authentication user and password in query is not required.
Import Meters
/api/server/meters
POST /api/server/meters
Description
This service imports the given meters to the inventory.
Parameters
Responses
Delete Meters
/api/server/meters
DELETE /api/server/meters
Description
This service deletes the given meters from the inventory. The meters are specified in the request body
as an array of strings (site IDs).
Parameters
Responses
Description
This service lists all existing routes.
Parameters
Responses
Description
This service returns status of the given route.
Parameters
Responses
Code Description Schema
200 Success –The response body contains JSON RouteStatusDTO
array of route names (strings).
401 Unauthorized – wrong or missing user and
password
402 Forbidden – the specified user is not in the
correct role (Service)
404 Not found – the given route does not exist
Assign Route
/api/server/route/{routeName}/assign
POST /api/server/route/{routeName}/assign
Description
This service assigns the given route to the given user.
Parameters
Responses
Export Inventory
/api/server/inventory
GET /api/server/inventory
Description
This service exports all meters in the inventory.
Parameters
Responses
Code Description Schema
200 Success – see the Model section. The response [ ExportMeterDTO ]
body contains JSON array of exported meters.
401 Unauthorized – wrong or missing user and
password
402 Forbidden – the specified user is not in the
correct role (Service)
Export Route
/api/server/route/{routeName}
GET /api/server/route/{routeName}
Description
This service exports meters for the given route.
Parameters
Responses
Delete Route
/api/server/route/{routeName}
DELETE /api/server/route/{routeName}
Description
This service deletes the given route.
Parameters
Responses
Delete Readouts
/api/server/readouts
DELETE /api/server/readouts
Description
This service deletes all readouts in the system from beginning to the given date.
Parameters
Responses
ImportMeterDTO {
# This model describes a meter data for the import
amrChannel: string *
amrDevice: string
amrMeterId: string
adcUnit: string
averageDailyConsumption: number (double)
city: string
customFields: { CUSTOM_FIELD1: string, … }
customerInfo: string
customerName: string
exDate: string (date-time)
exMeterId: string
exUnit: string
exValue: number (int64)
latitude: number (double)
longitude: number (double)
meterLocation: string
permissibleRelativeDeviation: number (double)
pulseWeight: number (double)
repeaterAddress: string
repeaterLatitude: number (double)
repeaterLongitude: number (double)
routeName: string
sequence: number (int32)
siteId: string *
siteNo: string
siteRemark: string
srfAddress: string
srfKey: string
stN1: string
stN2: string
street: string
unit: string *
zip: string
}
ImportAckDTO {
# This model describes result of the operation
status: string # OK or FAIL
errors: [ ImportErrorDTO ] # list of error in case of FAIL
}
ImportErrorDTO {
# This model describes a single error in import data.
index: number (int32) # index of the meter in the data
error: string # description of the error
field: string # field name where the error occurred
}
RouteStatusDTO {
# This model describes a status of a route
routeName: string # route name
status: string # status of the route
Possible values:
"DEFINED"
"ASSIGNED"
"IN_PROGRESS"
"FINISHED"
ExportMeterDTO {
# This model describes a meter data for the export
amrChannel: string
amrDevice: string
amrMeterId: string
adcUnit: string
averageDailyConsumption: number (double)
city: string
customFields: { CUSTOM_FIELD1: string, … }
customerInfo: string
customerName: string
latitude: number (double)
longitude: number (double)
meterLocation: string
permissibleRelativeDeviation: number (double)
pulseWeight: number (double)
repeaterAddress: string
repeaterLatitude: number (double)
repeaterLongitude: number (double)
readouts: [ ExportReadoutDTO ] # list of readouts
siteId: string
siteNo: string
siteRemark: string
srfAddress: string
srfKey: string
stN1: string
stN2: string
street: string
unit: string
zip: string
}
ExportReadoutDTO {
# This model describes readout data
actualDateAndTime: string (date-time)
airInServiceEnd: string (date-time)
airInServiceStart: string (date-time)
alarms: [ string ]
alarmActiveInformation: string (byte)
amrMeterId: string
averageDailyConsumption: number (double)
backflowEnd: string (date-time)
backflowStart: string (date-time)
backwardVolume: number (int32)
batteryEndDetected: string (date-time)
batteryLowDetected: string (date-time)
batteryRemaining: string (date-time)
brokenPipeEnd: string (date-time)
brokenPipeParams: string
brokenPipeStart: string (date-time)
comment: string
currentFlow: number (int32)
customFields: {
CUSTOM_FIELD1: string, …
}
customerSpecificText: string
date: string (date)
dayOfTheMonth: number (int32)
directionDetection: number (int32)
enhancedMbusAddress: number (int64)
fixedDateReadingContent: number (int32)
historicalErrorLimit: number (int32)
latInterval: number (int32)
leakEnd: string (date-time)
leakStart: string (date-time)
leakageParams: string (byte)
logContent: number (int32)
loggingInterval: number (int32)
mBusStatus: string
mBusTransmissionInterval: number (int32)
magneticTamperEnd: string (date-time)
magneticTamperStart: string (date-time)
maximumFlow: number (int32)
meterId: string
meterLocation: string
meterSerialId: number (int32)
meterSizeId: number (int32)
moduleRemovedEnd: string (date-time)
moduleRemovedStart: string (date-time)
numberOfDials: number (int32)
permissibleRelativeDeviation: number (double)
pulseWeight: number (double)
readoutStatus: string
Possible values:
"MANUAL_READ"
"NOT_READ"
"IN_PROGRESS"
"AUTOMATIC_READ"
"AUTOMATIC_READ_ALARM"
"WRONG_KEY"
"WRONG_KEY_READ_MANUALLY"
semiPulseWeight: number (double)
semiType: string
Possible values:
"UNKNOWN"
"E_REGISTER"
"I_PERL"
"PULSE_RF"
semiUnit: string
timeOfFDRReset: string (date-time)
timeOfLogReset: string (date-time)
timeOfMaximumFlow: string (date-time)
type: string
Possible values:
"IMPORT"
"MANUAL"
"BUP"
"SEMI"
"WMBUS"
"FDR"
transmissionInterval: number (int32)
unit: string
value: number (int64)
wmbusManufacturer: string
wmbusGeneration: number (int32)
wmbusSerial: string
wmbusUserSerial: string
wmbusUserManufacturer: string
wmbusDevice: number (int32)
wmbusVersion: number (int32)
wmbusMedium: number (int32)
plainAlarms: number (int32) # wmbus alarms
wmbusCounters: [ ExportWMbusCounterDTO ] # list of
counters
}
ExportWMbusCounterDTO {
# This model describes wmbus counter
order: number (int32)
storage: number (int64)
tariff: number (int32)
subUnit: number (int32)
type: string # function field
Possible values:
"INST" # Instantaneous value
"MAX" # Maximum value
"MIN" # Minimum value
"ERROR" # Value during error state
vif: number (int32) # value info field
vifType: string # value info field text description
flow: boolean
customDescription: string
value: number (double)
unit: string
}
Formats
The models must be encoded in valid JSON format. The following table defines the format for the field
types.
Type Description
string Any character string encoded in UTF-8 character set
Number (int32/int64) A valid JSON integer number
number (double) A valid JSON floating point value (e.g.: 21.4548)
date (string) A string in the form of yyyy-MM-dd. The date and time is specified
according to server time zone.
date-time (string) A string in the form of yyyy-MM-dd hh:mm:ss. The date and time is
specified according to server time zone.
Some of the fields from ImportMeterDTO must be in specific format. The table below defines the
formats.
For display a value with unit in CM (both server and Android) only these
units are permitted (ml, l, m3, Wh, kWh, MWh, kJ, MJ, GJ, Gal (UK), Gal
(US), mft3, kg)
For other units the unit and value have to be transformed to one of the
above units with use of Pulse Weight, e.g.
15 dcl (unit: milliliter; Pulse Weight: 100) = 1 500 ml
This example shows how to get the list of all routes and their statuses. The user is authenticated using
user and password in the request URL.
Request URL:
GET http://<server>/SensusServer/api/server/routes?user=service&password=service
Request Headers:
Content-type: application/json; charset=utf-8
This example shows how to get status of route TEST1. The user is authenticated using HTTP Basic Access
Authentication request header. The credentials are encoded using Base64 encoding.
Request URL:
GET http://<server>/SensusServer/api/server/route/TEST1/status
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl
This example shows how to import meters. Authentication done using HTTP request header.
Request URL:
POST http://<server>/SensusServer/api/server/meters?update=true&dateFormat=yyyy-MM-
dd&createRoutes=true
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl
Request BODY:
[
{
"routeName":"TEST1",
"sequence":2,
"siteId":"156446",
"street":"Dornych",
"stN1":"90",
"city":"Brno",
"siteRemark":"Be aware of dogs",
"customerName":"Jan Novak",
"unit":"m3",
"exMeterId":"8SEN0310001135",
"pulseWeight":1,
"amrChannel":"SensusRF",
"amrDevice":"eRegister 433",
"srfAddress":"1031-000-1135"
}
]
This example shows how to import routes. Authentication done using HTTP request header.
Request URL:
POST http://<server>/SensusServer/api/server/routes
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl
Request BODY:
[
{
"siteId":"11065215404",
"sequence":1,
"routeName":"TEST3"
},
{
"siteId":"11065215405",
"sequence":2,
"routeName":"TEST3"
}
]
Assigning a Route
This example shows how to assign route TEST1 to user reader. Authentication done using HTTP request
header.
Request URL:
POST http://<server>/SensusServer/api/server/route/TEST1/assign?assignTo=reader&
scheduledDate=2017-05-20
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl
This example shows how to export route TEST1. Authentication done using HTTP request header.
Request URL:
GET
http://<server>/SensusServer/api/server/route/TEST1?readOnly=false&historical=true&type=ALL&st
artDate=1/1/2018&endDate=1/12/2018&dateFormat=dd/MM/yyyy&dateTimeFormat=dd/MM/yyyy%20HH:mm
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl
This example shows how to export all meters in the inventory. Authentication done using HTTP request
header.
Request URL:
GET
http://<server>/SensusServer/api/server/inventory?historical=true&type=ALL&startDate=1/1/2018&
endDate=1/12/2018&dateFormat=dd/MM/yyyy&dateTimeFormat=dd/MM/yyyy%20HH:mm
Response format and error codes for this service call are identical as for exporting a route.
Deleting a Route
This example shows how to delete route TEST1. Authentication done using HTTP request header.
Request URL:
DELETE http://<server>/SensusServer/api/server/route/TEST1
Request Headers:
Content-type: application/json; charset=utf-8
Authorization: Basic c2VydmljZTpzZXJ2aWNl