Overview

Updated at:

External applications can access IoT Edge through the edge HTTP API to retrieve device information, set device properties, and invoke Function Compute functions.

The edge HTTP API provides services on port 9999. To ensure secure transmission, all APIs support only the HTTPS protocol.

Authentication and authorization

HTTP APIs currently support access through cookie-based authentication. Developers must call the CreateAuthCookie API to obtain an authentication cookie before calling other APIs. The steps are as follows.

  1. Log on to the edge gateway console at the following address to configure API access permissions.
    https://{ip}:9999

    In the address, {ip} is the IP address of the machine where the gateway is located.

    Note The initial username is admin and the password is admin1234. Change the username and password after you log on to the edge gateway console.
  2. Call the CreateAuthCookie API to create an authentication cookie.
    CreateAuthCookie API uses the Basic Authentication method. The authentication identity is passed in the Authorization field of the HTTP request header.

    The format of the Authorization field is as follows.

    Authorization: Basic <base64(username:password)>

    In this format, base64(username:password) is the Base64-encoded string of the <username:password> used to log on to the edge gateway console.

    For example, if the username is admin and the password is admin1234, the Authorization field is as follows.

    Authorization: Basic YWRtaW46YWRtaW4xMjM0
  3. From the HTTP response header of the CreateAuthCookie API, retrieve the value of the Set-Cookie parameter.
    Set-Cookie field is as follows.
    Set-Cookie: token=d71020ad5cb58faf04a6fd81d6df9680582b987eb6d0ce7b33bc3a3e4f******; Max-Age=3600; Path=/
  4. Use the Set-Cookie value from the API response header as the value for the Cookie parameter in the HTTP request headers of other APIs.
    The format of the Cookie parameter in the HTTP request header is as follows.
    Cookie: token=d71020ad5cb58faf04a6fd81d6df9680582b987eb6d0ce7b33bc3a3e4f******; Max-Age=3600; Path=/
  5. When calling HTTP APIs other than CreateAuthCookie, pass the authentication token in the Cookie field of the HTTP request header. IoT Edge validates that the token has the required access permissions for the API.

API list