Axis devices strongest API is probably the Parameter API, this API is lightweight, but can control most of the settings that you’re interested in doing. You can for instance
- Control default Image settings
- Create events (Firmware less than 5.40)
- Get Device capabilities
- Control network settings
- … And so much more
Not only is it universal for every single camera since firmware 4.00 (Meaning more than six year old devices) it’s also super easy to use!
The base url to the parameter management is always the same:
/axis-cgi/param.cgi
To get all parameters:
/axis-cgi/param.cgi?action=list
This will give you a complete list of every parameter there is in a device. If you want to be more specific:
/axis-cgi/param.cgi?action=list&group=Properties
Now you will get all the every parameter in the Properties group. Interested in more than just the properties? Try this:
/axis-cgi/param.cgi?action=list&group=Properties,System
Now it’s not only the properties but also the system parameters. How about wildcards? It’s supported! For instance, you could be interested in what the direction of the IO ports are set. Try this:
/axis-cgi/param.cgi?action=list&group=IOPort.*.Direction
This can give you:
root.IOPort.I0.Direction=input
root.IOPort.I1.Direction=output
Awesome! Very easy to use and equally powerful. What about updating parameters though?
It’s as easy! same base url but your action changes from list to update, etc:
/axis-cgi/param.cgi?action=update&IOPort.I0.Direction=output,IOPort.I1.Direction=input
Now we changed the direction of the two IO ports listed above!
Note: If you want to update more parameters than what’s allowed in the HTTP GET URI length you can always use HTTP POST.
But wait! What about error handling? It’s there, if all goes through, the reply back will be an easy going
OK
Otherwise, you will get something like:
# Error: Error -1 getting param in group ‘IOPort.Fakeparam’
The same goes for updating parameters:
# Error: Error setting ‘IOPort.Fakeparam’ to ‘fakevalue’
Again, very easy to use. HTTP responses will be always be 200 OK for simple parsing of the HTTP headers.
Parameter cgi will also let you add and remove parameters, but these are mostly used for legacy events and aren’t really used anymore, so I’ll skip them.
Alright, so we’ve covered how to receive and get current settings using the parameter api. But what about if you want to list the settings in a UI? Is that possible without looking into the Camera web page and alter your integration per camera? As we discussed in the first Axis post, a driver should be as dynamic as possible.
The answer to this question is called listdefinitions.
List definitions will give you the parameters in an XML response instead of the plain response. The difference? It holds the possible values as well! Url:
/axis-cgi/param.cgi?action=listdefinitions&listformat=xmlschema
Take for instance the AudioSource format:
This response gives you all the values you need to make a nice UI setup. AudioSource A0 is currently running g711 as audio codec, but g726 and aac are available as well. What is even sweeter is the niceValue that gives you a nice looking value to present to the user. So what would you do to change the value of the Audiosource? Simple, the update action in param.cgi:
/axis-cgi/param.cgi?action=update&AudioSource.A0.AudioEncoding=aac
If your response is OK your coming connections with RTSP will be having AAC as the audio encoding. Easy? Sure is!
This covers the Parameter management API, if you want to read the reference, it’s on the Axis web page:
http://www.axis.com/files/manuals/vapix_parameter_management_52931_en_1307.pdf