Conguring the REST API
The REST API can be congured on Junos OS devices using commands available under the [edit system
services rest] hierarchy level. Once congured, the REST API becomes available as the rest service, a
REST-based interface that enables you to submit rpc commands to the device from a remote locaon,
and supports GET and POST requests.
To enable the REST API on your device, you need to congure:
• Control parameters— These allow you to oponally specify permied source IP addresses and
connecon limits common to both HTTP and HTTPS connecons.
• REST API Explorer— The REST API provides a GUI called the REST API Explorer, which allows you to
easily and quickly learn how to use the REST API. It is disabled by default, and can be enabled by
specifying set system services rest enable-explorer. To learn more about the REST API Explorer, see
"Example: Using the REST API Explorer" on page 13.
• HTTP access— You can specify a list of addresses and TCP ports for incoming connecons. HTTP
connecons are not secure because they exchange credenals and data in clear text, so we
recommend using HTTPS.
• HTTPS access (
recommended
)— You can specify a list of addresses and TCP ports for incoming
connecons, a list of preferred cipher suites, transport layer security (TLS) mutual authencaon, and
server cercates. HTTPS connecons are secure, encrypng both credenals and informaon.
• Trace opons— You can enable tracing for lighpd, User Interface Script Environment (juise), or both.
Trace informaon for lighpd is stored at /var/chroot/rest-api/var/log/lighpd, and trace
informaon for juise is stored at /var/chroot/rest-api/var/log/juise. Tracing is disabled by default.
To congure the oponal control parameters for sengs common to both HTTP and HTTPS
connecons:
1. Specify set system services rest control allowed-sources [
value-list
] to set the permied IP addresses
for both HTTP and HTTPS connecons. Use spaces as delimiters between values.
2. Specify set system services rest control connection-limit
limit
to set the maximum number of allowed
simultaneous connecons for both HTTP and HTTPS connecons. You can assign a value from 1
through 1024 (the default is 64).
To congure HTTP access:
1. Specify set system services rest http addresses [
addresses
] to set the addresses on which the server
listens for incoming HTTP connecons.
2.
Specify set system services rest http port
port-number
to set the TCP port for incoming HTTP
connecons. You can assign a value from 1024 through 65535 (the default is 3000).
6