Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

RESTful API Overview

The 100% API architecture of Juniper Mist backs every visible feature in the Juniper Mist portal. Anything that you can do in the portal, you can automate at scale by using the API. Representational State Transfer (REST) is a stateless client-server architecture with a uniform interface. Since machines have no use for a user interface, APIs allow for a defined and faster way for machines to communicate with each other. APIs also enable you and other users to create your own way of interacting with systems and applications. You can even create custom features.

The Juniper Mist API is available to any customer with a Juniper Mist account.

Juniper Mist API Architecture

Juniper Mist uses REST APIs, which use HTTP methods (GET, POST, PUT, and DELETE) to transfer data in JavaScript Object Notation (JSON) format.

RESTful API Requests

Using RESTful APIs follows a similar practice to the CRUD (CREATE, READ, UPDATE, DELETE) methodology used in development. These are the four basic actions or functions used when working with data.

Table 1: Basic CRUD Actions
CRUD HTTP/REST
Create POST
Read GET
Update PUT
Delete DELETE

REST commands include:

  • POST: Create an object.

  • GET: List objects.

  • PUT: Update an object.

  • DELETE: Remove an object.

To perform any actions on the REST API, you need to fulfill a few requirements in each request, such as:

  • Authentication: You can use an API token, Juniper Mist login credentials, or an external OAuth2 provider.

  • HTTP Header: This header specifies the content and the authorization type, as follows:

    • For Juniper Mist, the content type is always application/json.

    • The authorization can be a token or a cookie (including CSRF token and session ID).

  • API Endpoint

  • JSON Payload

API Endpoint URL Format

The API endpoint URL has two parts:

  • API Endpoint—The endpoint for the global region that your Juniper Mist organization is associated with. See API Endpoints and Global Regions.

  • Function—Everything after the API endpoint represents the function that the API will call.

Example

https://<api-endpoint>/api/v1/sites/:<site-id>/stats/devices/:<device_id>.

Note:

You would replace the bracketed items with the actual values for your API endpoint, site ID, and device ID.

Everything after <api-endpoint> is the function. The call goes to the global cloud and requests the statistics for the specified device at the specified site.

JSON Payload

Different functions require different elements in the JSON payload. You can view the required details in the API documentation.

How to view the API documentation:

  1. Log in to your Juniper Mist portal.

  2. Click the Help button (near the top right corner of the screen).

  3. Click API Documentation.

API Rate Limiting

Juniper Mist limits API calls to 5,000 per hour. If you need a higher rate limit, contact Juniper support about your use case.

Note:

To prevent brute-force attacks, the login API (/api/v1/login) is rate-limited after three login failures.

API Authentication Options

The Juniper Mist API allows three options for requesting authentication:

  • Basic Authentication—Token

    • Secure it like a password.

    • For instructions about creating an API token, see Creating API Tokens.

  • HTTP Login— Username and Password

    • Is like a dashboard login.

    • Can be two-factor authentication.

  • OAuth2

    • Account must be linked to an OAuth provider.

    • Requires browser access.

A Simple API Example

Using the Django API interface, you can make your first API call. After logging in to Mist, open a new window using the same browser and enter the URL https://api.mist.com/api/v1/self.

This is equivalent to making this API call GET /api/v1/self.

The result, shown above, displays the privileges assigned to you for the organizations and sites you are associated with.