Each firewall and Panorama provides an API browser that is accessible from your web browser. The API browser lets you navigate through and view the corresponding XPath and API URL.
Use the API Browser to Explore the API
Launch the web interface.
Use a web browser to navigate to the actual FQDN or IP address of your firewall:
https://firewall/
Log in with your administrator credentials when prompted to log in to the web interface.
Launch the API Browser.
Go to the API browser URL on your firewall:
https://firewall/api
Drill-down to a request.
When you first open the API browser, the available
Request Types display.
Select one of the request types to drill down to the next level of the XPath. Let’s start with Configuration Commands, which equates to
type=report
:
Drill down further until you select a request that you want to test.
Test a request.
Select the URL to then test that request in the browser.
The browser shows the resulting XML response in the browser:
Along with the URL, the API browser also provides the XPath as necessary, as shown here for a description of a predefined application:
Use the CLI to Find XML API Syntax
Another method to determine the appropriate XML syntax and XPath for your API calls is through the command-line interface (CLI). This method works for
type=op
and
type=config
API calls.
Use the CLI to enable debug mode and then run the CLI command to receive the corresponding XML and XPath in the response.
Enter and run a CLI command. Example:
test url http://paloaltonetworks.com
<request cmd="op" cookie="7581536015878829" uid="1206"><operations><test><url>http://paloaltonetworks.com</url></test></operations></request>
Use the resulting response to create an API call.
Use the
cmd
value and the XML elements within the
operations
tag to form the API call:
https://firewall/api/?type=op&cmd=<test><url>http://paloaltonetworks.com</url></test>&key=apikey
Depending on the CLI command, the XML tag values for
cmd
will vary. For example, here is a CLI command for showing firewall information:
run show system info
The corresponding API call looks like this:
https://firewall/api/?type=op&cmd=<show><system><info></info></system></show>&key=apikey
Use the Web Interface to Find XML API Syntax
You can use the web interface along with the available debug console to explore the XML and XPath necessary for your API calls.
First log into the web interface and then open a separate window where you can view the corresponding XML and XPath.
Use the Web Interface and Debug Console to Find XML API Syntax and XPath
Launch the web interface.
Launch a web browser and enter the firewall’s IP address or hostname. Enter your user credentials.
Launch the debug console.
In a separate web browser window or tab, launch the debug console:
http://firewall/debug
Perform the action you want to replicate through the API.
In the web browser, navigate to the menu and item or action that you want to perform.
To aid in finding the relevant XML, select
Clear
in the debug console just before you select the final menu or action.
View the resulting XML syntax in the debug console.
In the debug console, select
Refresh
and then navigate through the console to the syntax related to your choice or action:
Example XML within debug console:
<request cmd="op" cookie="3885378180190727">
<operations xml="yes">
<show>
<system>
<info/>
</system>
</show>
</operations>
</request>
The corresponding API call looks like this:
https://firewall/api/?type=op&cmd=<show><system><info></info></system></show>&key=apikey