Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

openflighthub-api-client-sdk

openflighthub102MIT2.14.0TypeScript support: included

This is a typescript sdk made to talk to the OpenFlightHub Api. It must be run in the browser!

flight, hub, drone, dji

readme

OpenFlightHub API Client SDK

This is a typescript sdk made to talk to the OpenFlightHub Api. It must be run in the browser!

Features

  • typescript typings (for parameters, request bodies and returned data)
  • automatically handles idempotency

Dependencies

  • none

Usage

install via npm:

npm i --save openflighthub-api-client-sdk
import {OpenFlightHubApi} from 'openflighthub-api-client-sdk'

const api = new OpenFlightHubApi({
    restApiBaseUrl: 'https://hub.openflighthub.org/api',
    liveWebsocketBaseUrl: 'wss://hub.openflighthub.org/api/live'
})

// Version

console.log('API Version', api.rest.API_VERSION)
console.log('Client SDK Version', api.VERSION)


// Login

api.rest.auth.login.post({
    username: 'test@openflighthub.org',
    password: '1234'
}).then(response => {
    const myUserId = response.id
})

// Get information for a drone

const FAKE_DRONE_ID = 1

api.rest.drone.get({
    droneId: FAKE_DRONE_ID
}).then(drone => {
    console.log(drone.serial_number)
})

// Get last position of drone

api.rest.drone.lastPosition.get({
    droneId: FAKE_DRONE_ID
}).then(lastPosition => {
    console.log(lastPosition.latitude, lastPosition.latitude)
})

// Get live positions of drone via websocket

api.live.subscribeToDrone(FAKE_DRONE_ID, (event, filter, data)=>{
    console.log('new position of drone', data.id, data.position.latitude, data.position.longitude)
})



// Live connection status

api.live.status.addListener('connected', () => {
    console.log('api is connected')
})

api.live.status.addListener('disconnected', reason => {
    console.log('api is disconnected')
})

Changelog

see CHANGELOG.md

For Developers

see dev/README.md

changelog

2.14.0 (25. Apr 2025)

  • BREAKING: refactor media created_at to received_at and captured_at
  • add workspace location
  • add media camera meta

2.13.0 (22. Apr 2025)

  • add flight_id to media events

2.12.0 (22. Apr 2025)

  • add flight_id to media objects

2.11.0 (22. Apr 2025)

  • add /flight/media endpoint
  • change /workspace/files endpoint so it returns full file data (like /file)

2.10.1 (18. Apr 2025)

  • fix return type of /drone/current-flight

2.10.0 (18. Apr 2025)

  • add /file/get-multiple
  • add endpoints for flights
  • add /media/ground-coverage

2.9.0 (15. Apr 2025)

  • add file_id and drone_serial_number to drone media events

2.8.0 (14. Apr 2025)

  • add has_thumbail to file
  • add helpers for file and thumbnail url

2.7.0 (13. Apr 2025)

  • add file_name and drone_id to media object

2.6.0 (13. Apr 2025)

  • add media endpoint

2.5.0 (13. Apr 2025)

  • add events drone_media and workspace_drones_media

2.4.0 (11. Apr 2025)

  • add property name to workspace connection
  • change reference system for connections and drones (drones have a last_connection_id property)

2.3.0 (04. Apr 2025)

  • add workspace_drone_positions event
  • add serial_number property to drone position

2.2.1 (02. Apr 2025)

  • change rest api timeout
  • add ws_url for for dji pilot sdk config

2.2.0 (27. Feb 2025)

  • add property workspace_uuid for /connection-link/config response data

2.1.0 (27. Feb 2025)

  • add /connection-link/reset-workspace-uuid endpoint

2.0.0 (20. Feb 2025)

  • revert the live part of the sdk to version 1.2.0 (which removes the changes to the filter system) and implement new braking changes for events. Also marked version 1.3.0 and 1.4.0 as BREAKING (they should have been a major version).

1.4.1 (20. Feb 2025)

  • fix ts type Message_Type_Event_Object_Data_Drone_Telemetry

1.4.0 (20. Feb 2025)

BREAKING CHANGE

  • implement filter separators

1.3.1 (20. Feb 2025)

  • fix ts type in subscribeToRemoteController()

1.3.0 (20. Feb 2025)

BREAKING CHANGE

  • add live remote_controller and drone telemetry and position

1.2.0 (20. Feb 2025)

  • add new endpoints for files and media

1.1.0 (27. Jan 2025)

  • add traffic event

1.0.2 (26. Jan 2025)

  • fix client sdk version property
  • BREAKING implement live api user friendly
  • update usage example

1.0.1 (26. Jan 2025)

  • fix this binding in LiveWebsocket.handleMessage()

1.0.0 (26. Jan 2025)

  • Reimplemented live websocket

0.1.0 (26. Jan 2025)

  • Initial version