Overview
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.
- Log on to the edge gateway console at the following address to configure API access permissions.
https://{ip}:9999In 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. - Call the CreateAuthCookie API to create an authentication cookie.
CreateAuthCookie API uses the Basic Authentication method. The authentication identity is passed in the
Authorizationfield 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
Authorizationfield is as follows.Authorization: Basic YWRtaW46YWRtaW4xMjM0 - From the HTTP response header of the CreateAuthCookie API, retrieve the value of the
Set-Cookieparameter.Set-Cookiefield is as follows.Set-Cookie: token=d71020ad5cb58faf04a6fd81d6df9680582b987eb6d0ce7b33bc3a3e4f******; Max-Age=3600; Path=/ - Use the
Set-Cookievalue from the API response header as the value for theCookieparameter in the HTTP request headers of other APIs.The format of theCookieparameter in the HTTP request header is as follows.Cookie: token=d71020ad5cb58faf04a6fd81d6df9680582b987eb6d0ce7b33bc3a3e4f******; Max-Age=3600; Path=/ - When calling HTTP APIs other than CreateAuthCookie, pass the authentication token in the
Cookiefield of the HTTP request header. IoT Edge validates that the token has the required access permissions for the API.
API list
- Identity authentication APIs
API name API description CreateAuthCookie Creates an authentication cookie. DeleteAuthCookie Deletes an authentication cookie. - Device management APIs
API name API description ListThings Lists devices and their statuses. SetThingProperties Sets device properties. GetThingProperties Gets device properties. CallThingServices Calls device services. BulkActions Performs batch operations on devices. - Function Compute APIs
API name API description InvokeFunction Invokes a specified function.