Airspace Management
Feature Description
After enabling real-time airspace data reporting, you can obtain a Webhook URL and an encryption token from your service provider. After entering and saving them, the FlightHub API can push real-time aircraft data to third parties. The following is the integration guide for third-party service providers.
Integration Guide
Data Reporting Protocol
1. Request Header
| Field Name | Field Code | Data Type | Description | Required |
|---|---|---|---|---|
| Data Source | source | Integer | 1: Reported directly by aircraft2: Reported by manufacturer's system3: Reported by add-on module4: Reported by collection device | Yes |
| Reporting Platform | platform | String | Platform name (e.g., DJI Fly) | Yes |
| Program Version | programVersion | String | Version number (e.g., version 1.0) | Yes |
| Signature | signature | String | The generated request signature | Yes |
| Request timestamp | timestamp | String | Request Unix timestamp (in seconds) | Yes |
| Nonce | nonce | String | A randomly generated string | Yes |
Signature Generation Process
Input Parameters
token: Application key (provided by the integrated service provider and configured by the user in FlightHub 2). Must be 32-64 characters long and consist of a combination of at least three of the following types: letters, numbers, and special symbols.timestamp: Request timestamp (from thetimestamprequest header)nonce: Random string (from thenoncerequest header)body: Raw byte data of the request body (e.g., the JSON-serializedRequestBody)
Signature Rules
- Concatenate
timestamp,nonce, andbodyinto a single string in that order (without separators). - Use the HMAC-SHA256 algorithm with the
tokenas the key to encrypt the concatenated string. - Convert the encrypted result to a lowercase hexadecimal string.
Go Code Implementation
import (
"crypto/hmac"
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
)
func GenerateHMACSignature(appKey, timestamp, nonce string, body []byte) string {
mac := hmac.New(sha256.New, []byte(appKey))
mac.Write([]byte(timestamp))
mac.Write([]byte(nonce))
mac.Write(body)
return hex.EncodeToString(mac.Sum(nil))
}
Signature Verification Process
Verification Logic
- The server retrieves the following from the request header:
signature: The signature generated by the clienttimestamp: The request timestampnonce: The random string
- The server regenerates a signature using the same parameters and the secret key
appKey. - Use a constant-time comparison to verify if the client's signature matches the one generated by the server.
Go Code Implementation
func VerifyHMACSignature(appKey, timestamp, nonce string, body []byte, signature string) bool {
expected := GenerateHMACSignature(appKey, timestamp, nonce, body)
return subtle.ConstantTimeCompare([]byte(expected), []byte(signature)) == 1
}
2. Request Body
JSON format
{
"app_id":"default",
"flight_hub_organization_id":"xxxx",
"paths": [
{ /* FlightPath object */ },
{ /* FlightPath object */ }
]
}
Field Descriptions
| Field | Type | Required | Description |
|---|---|---|---|
app_id | string | Yes | Unique application identifier. Currently defaults to default. |
flight_hub_organization_id | string | Yes | User's FlightHub organization ID |
paths | FlightPath[] | Yes | Array of flight path data (see object structure below) |
FlightPathRecord Structure Description
This structure is used to describe flight path point data. The following are detailed field descriptions:
| No. | Field Name | Field Code | Data Type | Description | Required |
|---|---|---|---|---|---|
| 1 | Flight Record ID | order_id | String | Format: Manufacturer Serial Number (sn)-8-digit takeoff date (YYYYMMDD)-8-digit random code.Example: 1581F5FHD25G100C1SDN-20240320-owvGyLqe.The same ID is used throughout the entire flight. | Yes |
| 2 | Aircraft Serial Number | sn | String | Manufacturer's aircraft production SN | Yes |
| 3 | Flight Status | flight_status | String | TakeOff: takeoff point, Inflight: In flight, Land: Landing point | Yes |
| 4 | Unified Social Credit Code | manufacturer_id | String | The manufacturer's Unified Social Credit Code. | Yes |
| 5 | CAAC Real-name Registration Number | uas_id | String | If there is no registration number, use the default value UAS-DEFAULT. | Yes |
| 6 | Current Timestamp | time_stamp | String | UTC+8 time, format: yyyyMMddHHmmss. Example: 20240124095001 | Yes |
| 7 | Product Model | uas_model | String | A combination of letters, numbers, and/or symbols. | Yes |
| 8 | Coordinate System Type | coordinate | Integer | 1: WGS-842: CGCS20003: GLONASS-PZ90 | Yes |
| 9 | Longitude | longitude | Long | Unit: degrees (°). Actual value = field value / 10⁷. | Yes |
| 10 | Latitude | latitude | Long | Unit: degrees (°). Actual value = field value / 10⁷. | Yes |
| 11 | True Height Type | height_type | Integer | 1: Altitude relative to takeoff point (ALT)2: Altitude relative to current position (AGL) | Yes |
| 12 | True Height | height | Integer | Unit: meters (m). Actual value = field value / 10. | Yes |
| 13 | Altitude | altitude | Integer | Unit: meters (m). Actual value = field value / 10. | Yes |
| 14 | Vertical Speed | vs | Integer | Unit: m/s. Actual value = field value / 10. | Yes |
| 15 | Horizontal Flight Speed | gs | Integer | Unit: m/s. Actual value = field value / 10. | Yes |
| 16 | Course | course | Integer | Angle clockwise from True North (0°-360°). Actual value = field value / 10. Fill with -999 when no data is available. | Yes |
| 17 | RID Broadcast Status | remote_id_status | Integer | 0: Disabled 1: Enabled | Yes |
Body Example:
{
"app_id": "default",
"flight_hub_organization_id": "105ddf05-54ce-4626-a872-cb32b8c98864",
"paths": [{
"order_id": "1529F6QAD23CB00A42DP-20251028-89W2aK2W",
"sn": "1529F6QAD23CB00A42DP",
"flight_status": "Land",
"manufacturer_id": "925413007954257495",
"uas_id": "UAS-DEFAULT",
"time_stamp": "20251028115000",
"uas_model": "M3D",
"coordinate": 1,
"longitude": 1243579943,
"latitude": 217931488,
"height_type": 1,
"height": 0,
"altitude": 187,
"vs": 0,
"gs": 0,
"course": 1229,
"remote_id_status": 1
}]
}
3. Response Body
| Field Name | Field Code | Data Type | Description |
|---|---|---|---|
| Status Code | code | String | 0 = Success, 400 = Failure |
| Result Description | result | String | Detailed description (e.g., success) |
Response Example:
{
"code": "0",
"result": "success"
}