People counter API

AXIS People Counter is an application accessible on your indoor Axis camera that provides simultaneous two-way counting of people, which lets you analyze visitor trends such as peak visitor hours. It is also able to estimate occupancy levels in real-time and provide access to data on the number of people present on either the premises or in a certain area at a certain time. This is helpful when you want to understand occupancy trends that enables you to measure if the occupancy levels exceed a set threshold.

Additionally, the application can detect and notify if more than one person enters within a set time interval or move in the wrong direction. This means that if you set up the application over a one-way entrance you will receive a notification whenever someone tries to leave or if more than one person tries to enter at the same time.

Common examples

Request real time data from the People Counter

Request
http://<servername>/local/tvpc/.api?live-sum.json
Return
{
  "serial":"00408CAC512B",
  "name":"Exit south",
  "timestamp":"20170503112756",
  "in":12,
  "out":318
}

See Request real-time data for additional information.

List all days of data available on the People Counter

Request
http://<servername>/local/tvpc/.api?list-cnt.json
Return
{
  "timestamp" : "20170513132513",
  "days":["20170510", "20170511", "20170513"]}
}

See List available data for additional information.

Request historical data for the 12th to the 15th of May 2017

Request
http://<servername>/local/tvpc/.api?export-cnt&date=20170512-20170515

See Download binary data for additional information.

Request all available historical data

Request
http://<servername>/local/tvpc/.api?export-cnt&date=all

See Download binary data for additional information.

Request historical CSV data for the 12th and the 15th of May 2017 with 15-minute resolution

Request
http://<servername>/local/tvpc/.api?export-csv&date=20170512,20170515&res=15m

See Request CSV data for additional information.

Request historical data for all available days, with 24-hour resolution

Request
http://<servername>/local/tvpc/.api?export-csv&date=all&res=24h

See Request CSV data for additional information.

Request historical XML data for the 12th and the 15th of May 2017 with 15-minute resolution

Request
http://<servername>/local/tvpc/.api?export-xml&date=20170512,20170515&res=15m

See Request XML data for additional information.

Request Live view information from the People Counter

Request
http://<servername>/local/tvpc/.api?cntpos.json
Response
{
  "width":320,
  "height":240,
  "left":0,
  "right":296,
  "top":88,
  "bottom":224,
  "yfirst":88,
  "ylast":152,
  "radius":0
}

See Live view information for additional information.

API specification

Request real-time data

Returns JSON file with real time counting data.

Format

JSON

Method

GET

Request
http://<servername>/local/tvpc/.api?live-sum.json
Return
{
  "serial":"<camera-serial>",
  "name":"<counter-name>",
  "timestamp":"<timestamp>",
  "in":<in>,
  "out":<out>
}
Return value descriptions
ValueDescription
camera-serialcamera serial number
counter-namename of the counter
timestamptime in the camera in the format YYYYMMDDhhmmss
innumber of people passing in until now today
outnumber of people passing out until now

List available data

Returns a list of days where data exists.

Format

JSON

Method

GET

Request
http://<servername>/local/tvpc/.api?list-cnt.json
Return
{
  "timestamp" : "<timestamp>",
  "days":["YYYYMMDD", [..] "YYYYMMDD"]}
}
Return value descriptions
ValueDescription
timestamptime in the camera in the format YYYYMMDDhhmmss
daysan array of days where there exists

Download binary data

This script returns a binary data file for the given date(s), to be used in AXIS Store Data Manager

Format

cnt

Method

GET

Request
http://<servername>/local/tvpc/.api?export-cnt&date=<date>
Request parameter descriptions
ParameterDescription
datea date of the form YYYYMMDD
a date interval of the form YYYYMMDD-YYYYMMDD
comma separated dates of the form YYYYMMDD,[..],YYYYMMDD
all for all available data

Return

A binary data file for the given date(s).

Request CSV data

Returns historical data in CSV format

Format

CSV

Method

GET

Request
http://<servername>/local/tvpc/.api?export-csv[&date=<date>][&res=<res>]
Request parameter descriptions
ParameterDescription
datea date of the form YYYYMMDD
a date interval of the form YYYYMMDD-YYYYMMDD
comma separated dates of the form YYYYMMDD,[..],YYYYMMDD
all (default) for all available data
res15m (default) for data in 15 minute bins
1h for data in 1 hour bins
24h for data in 1 day bins

Return

This script returns data in plain text, comma-separated values. The first line contains a description of each element, and the following lines contain the corresponding data for the chosen time interval and resolution.

Request JSON data

Returns historical data in JSON format

Format

JSON

Method

GET

Request
http://<servername>/local/tvpc/.api?export-json[&date=<date>][&res=<res>]
Request parameter descriptions
ParameterDescription
datea date of the form YYYYMMDD
a date interval of the form YYYYMMDD-YYYYMMDD
comma separated dates of the form YYYYMMDD,[..],YYYYMMDD
all (default) for all available data
res15m (default) for data in 15 minute bins
1h for data in 1 hour bins
24h for data in 1 day bins

Return

This script returns data in JSON format.

Request XML data

Returns historical data in XML format

Format

XML

Method

GET

Request
http://<servername>/local/tvpc/.api?export-xml[&date=<date>][&res=<res>]
Request parameter descriptions
ParameterDescription
datea date of the form YYYYMMDD
a date interval of the form YYYYMMDD-YYYYMMDD
comma separated dates of the form YYYYMMDD,[..],YYYYMMDD
all (default) for all available data
res15m (default) for data in 15 minute bins
1h for data in 1 hour bins
24h for data in 1 day bins

Return

This script returns data in XML format. The DTD file can be found at: http://<servername>/local/tvpc/appdata.dtd

Clear counting data

Format

text/plain

Method

GET

Request
http://<servername>/local/tvpc/.apioperator?clear-data
Return
OK
Note
Please note that this method will permanently delete all counting data from your device.

Live view information

Returns information about the placement of the lines in Live view.

Format

JSON

Method

GET

Request
http://<servername>/local/tvpc/.api?cntpos.json
Response
{
  "width":<width>,
  "height":<height>,
  "left":<left>,
  "right":<right>,
  "top":<top>,
  "bottom":<bottom>,
  "yfirst":<yfirst>,
  "ylast":<ylast>,
  "radius":<radius>
}
Return value descriptions
ValueDescription
widthdimension of the video stream
height
leftx coordinates in pixels forstart and stop for the blue lines in Live view
right
topy coordinates in pixels for the two blue lines in Live view
bottom
yfirsty coordinates in pixels for the top and bottom of the red counting area, disregarding curvature
ylast
radiusradius in pixels describing the curvature of the red counting area, as measured in the center of the area on both axes, or if the area is not curved

Show the system log

Format

text/plain

Method

GET

Request
http://<servername>/local/tvpc/.apioperator?show-logs

Return

Displays the system logs.

Generate a log archive

Format

tar.gz

Method

GET

Request
http://<servername>/local/tvpc/.apioperator?generate-logs

Return

A log archive

List people counter parameters

Format

JSON

Method

GET

Request
http://<servername>/local/tvpc/.api?params.json

Return

A JSON object of all the People Counter related parameters.

Set people counter parameters

Format

text

Method

POST

The post format has a format where pairs and values need to be specified, best described by an example: &p1=Counter.Enable&v1=1&p2=Counter.Height&v2=280&setparams=needstobeincluded

Note
For Firmware-version 5.60 and later, use: setparams&Counter.Height=280 instead.
Request
http://<servername>/local/tvpc/.apioperator?setparams
Return
OK

Occupancy data

The occupancy data requests fetches the total number of people entering or leaving a location and their average visit time.

Note
Please note that occupancy data must be enabled in the settings page to be able to perform the requests listed in this section.

Request

Request historical data for all available days and a 24–hour resolution.

http://<servername>/tvpc/.apioperator?occupancy-export-json&date=all&res=24h

Response

{
  "counter": {
    "name": "Axis-ACCC8E019C5F",
    "serial": "ACCC8E019C5F",
    "delta": 86400,
    "types": {
      "Occupancy": 64,
      "Average Time": 64,
      "Total In": 66,
      "Total Out": 67
    }
  },
  "data":{
    “20170908000000” : [0,0,17,17],
    "20170909000000" : [0,0,18,17],
    "20170910000000" : [0,0,1,0],
    "20170911000000" : [0,0,0,0],
    "20170912000000" : [0,0,21,15],
  }
}
ParameterDescription
name

The name of the application, chosen by the client.

serial

The Mac address for the camera.

delta

The time difference between data entries, measured in seconds.

Occupancy

The number of people currently in the location.

Average time

Average time a person is staying in a location.

Total In

Total number of people entering a location.

Total Out

Total number of people leaving a location.

API specification

Real-time data

Request a JSON file with the real time occupancy data.

http://IPaddress/tvpc/.api?live-occupancy.json

Reset occupancy

Request a reset of the available occupancy data.

http://IPaddress/tvpc/.api?occupancy-reset&occ=[value]
Note
Please note that this method only works while the people counter is set to naïve mode. See the user manual for AXIS People Counter for additional information.

Export occupancy

Export the occupancy data by specifying a date and time frame using either the CSV, JSON or XML-format.

CSV
http://IPaddress/local/tvpc/.api?occupancy-export-csv&date=[date]&res=[res]
JSON
http://IPaddress/local/tvpc/.api?occupancy-export-json&date=[date]&res=[res]
XML
http://IPaddress/local/tvpc/.api?occupancy-export-xml&date=[date]&res=[res]
ParameterDescription

[date]

A date in the form YYYYMMDD, for example date=20180520
[res]1m for data in 1 minute bins.
15m for data in 15 minute bins.
1h for data in 1 hour bins.
24h for data in 24 hour bins.