Request Structure

This topic explains the structure of Milesight Development Platform API request, including HTTP request method, request URL, and request authentication.

Restrictions

Click here to check the maximum number of API requests under different plans.

Request example

The following example shows a request of Add a Device.

POST /device/openapi/v1/devices HTTP/1.1
Host: demo.milesight.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

{
    "snDevEUI": "66003649xxxx",
    "name": "Sample VS121-P",
    "description": "VS121-P on meeting room 3D",
    "project": "Workplace-management"
}

Request methods

Milesight Development Platform API supports the following HTTP methods:

HTTP method Usage
GET Query data from Milesight Development Platform.
POST Send data to Milesight Development Platform to create a new resource or perform a specific operation.
PUT Update an existing resource on Milesight Development Platform.
DELETE Delete a specific resource on Milesight Development Platform.
PATCH Used for incremental update of resource on Milesight Development Platform.

Request URL

The request URL format of Milesight Development Platform API is shown as follows:
{base_url}/{endpoint}
base_url
Base URL is the domain name of the server hosting the API, namely the server address of Milesight Development Platform:
https://{Milesight Development Platform server address}
After you Create an Application, you can find the server address in the Authentication section, use it as the base_url to make API calls.

endpoint
Endpoints represent different resources or functionalities that can be accessed and interacted with through the API. Milesight Development Platform API endpoints are constructed in the following format:
/{serviceName}/openapi/{version}/**
For all the available endpoints of Milesight Development Platform API, see API Interface List.

Request authentication

After the third-party application obtains an access token, it can use the token to make API calls. There are two ways to pass the access token to Milesight Development Platform API.
Note: The use of HTTP headers is generally preferred over query strings as the query string parameter appearing in URLs might be exposed. Therefore, this documentation will provide API examples based on the Authorization Bearer authentication method.
Using the Authorization Bearer HTTP Header (Preferred)
Send the access token in the Authorization:Bearer HTTP header, as the following code shows.
POST /service/openapi/v1/devices
Host: milesight.demo.com
Authorization: Bearer {access_token}
Using the access token querying string parameter
You can also send the access token via a querying string parameter access_token, as the following code shows.
POST https://demo.milesight.com/devices?access_token={access_token}