Rest API

Rest Overview:
-REpresentational State Transfer API architecture
-Typically uses HTTP(s) for transport
-No session state is stored on the server hosting the API, each query is independent.
-Commmonly uses HTTP GET and POST queries, simple tools like curl can be used for quick prototyping.

REST API for Junos
-Execute RPCs
-Currently supported in MX, M, T, PTX and SRX platforms
-HTTP(S) based interface
-Provides GUI API explorer
-Retrieve data in plain text, JSON and XML

To do API calls on your compatible device you need to enable them:

here I’m just doing http because I don’t want to worry about certificates

Example REST API call:

curl http://10.1.1.1:3000/rpc/get-software-information -u "root:juniper123" -H "content-Type: application/xml" -H "Accept: application/xml"

Benefits of REST API
-Easy to set up and configure
-Provides GUI API explorer which allows for rapid prototyping
-Does not require SSH or NETCONF
-Ability to retrieve data in text, JSON and XML
-Allows Junos devices to participate in REST management environments (secure connectivity over HTTPS and Execute Junos RPCs)

Junos REST API Architecture
-REST client makes HTTP(S) request
-lighttpd server terminates the HTTP(S) connection and passes request on to mod_juise plugin
-mod_juise invokes the Juniper User Interface Scripting Environment (JUISE)
-Authenticated request is passed onto the mgd