Difference between revisions of "Working with the JSON API"

From Zenoss Wiki
Jump to: navigation, search
Line 14: Line 14:

Revision as of 22:43, 7 December 2012

You can find API documentation for the Zenoss JSON API at http://docs.zenoss.org/. The accompanying files for this document include a shell script called json_api.sh. This is an example for using curl in a shell script to use the Zenoss JSON API.

The following example uses helper functions in json_api.sh to show the title and URL for the graphs on a particular device. Be sure to download json_api.sh for this example.

$ # Get the zenoss_api function by sourcing json_api.sh.
$ source json_api.sh

$ # Call the getGraphDefs method.
$ zenoss_api device_router DeviceRouter getGraphDefs '{"uid":"/zport/dmd/Devices/Server/Linux/devices/zenosstrain6.zenoss.com","drange":129600}'

The output of this command will be a JSON document that contains the title and graph URL for every graph on the device identified by the uid parameter above.