User Tools

Site Tools


api

Table of Contents

The UKHASnet API is exposed as a set of HTTP URLs behind ukhas.net/api/.

Program

The API daemon is written in Node.js and is run as a background daemon, at ukhas.net/api/

The source code can be found on github.com/UKHASnet-hub/general-api-daemon

URLs

For uploading packets see here.

  • /upload - POST
    • Uploads given data string into the Database for processing
    • Compulsory Request Parameters
      • origin: [string: callsign of gateway node]
      • data: [string: raw data]
    • Return Parameters
      • error: [integer: 0 if successful, 1 if failure]
  • /logtail - GET
    • Returns recent packet uploads and processing status of each
    • Optional Request Parameters
      • lastId: [integer: filter uploads since given row id]
    • Return Parameters
      • Array (can be 0 length)
        • i: [integer: Upload row id]
        • ni: [integer: Gateway Node id]
        • nn: [string: Gateway Node callsign]
        • t: [integer: Unix timestamp of upload]
        • p: [string: Raw packet]
        • s: [string: State of Packet Processing]
          • “Pending”, “Processed” or “Error”
  • /mapNodes - GET
    • Returns all nodes with a stored location, and their most recent information
    • Return Parameters
      • Array (can be 0 length)
        • i: [integer: Node id]
        • o: [string: Node owner/description]
        • a: [integer: Unix timestamp of most recent packet]
        • p: [string: Raw most recent packet]
        • la: [float: Most recent Latitude value]
        • lo: [float: Most recent Longitude value]
  • /nodeInfo - GET
    • Returns node Information, either for the node requested, or all nodes.
    • Optional Request Parameters
      • id: [integer: requested node id]
    • Return Parameters
      • Array (can be 0 length)
        • i: [integer: Node id]
        • n: [string: Node callsign]
        • o: [string: Node owner/description]
  • /nodeLData - GET Not currently Implemented
    • Returns info about the last packet from the node specified
    • Compulsory Request Parameters
      • id: [integer: requested node id]
    • Return Parameters
      • Array (can be 0 length)
        • lPacket: [string: Last raw packet from node]
        • lRxT: [integer: Timestamp of last packet (unix timestamp)]
        • lRxNi: [integer: Last packet gateway id]
        • lRxNn: [string: Last packet gateway callsign]
        • lBoot: [integer: Timestamp of last detected boot (sequence='a') (unix timestamp)]
  • /nodeData - GET
    • Returns graphable Data from the specified node
    • Compulsory Request Parameters
      • id: [integer: requested node id]
      • Exclusive Or:
        • since: [integer: Filter for data after this time (unix timestamp)]
        • period: [integer: Filter for data in this last time period (seconds)]
    • Return Parameters
      • Array (can be 0 length)
        • Array
          • i: [integer: Data type id]
          • tn: [string: Data type description]
          • n: [string: Data type description (short)]
          • d: Array
            • t: [integer: Data point timestamp (unix)]
            • d: [float: Data point value]
  • /lastData - GET
    • Returns last data value and name of the specified type from the specified node
    • Compulsory Request Parameters
      • id: [integer: requested node id]
      • type: [integer: requested data type]
    • Return Parameters
      • Object (can be 0 length)
        • data: [float: data value]
        • pos: [integer: data position in string]
        • typeid: [integer: data type requested]
        • type: [string: Name of data type]
        • unit: [string: Unit of data type]
        • time: [string: ISO8601 Timestamp of data value]
  • /addNode - POST
    • Adds a Node to the database
    • Compulsory Request Parameters
      • id: [string: Node callsign]
      • owner: [string: Node owner/description]
    • Return Parameters
      • error: [integer: '0' for successful, otherwise error]
  • /editNode - POST
    • Edits a node owner/description
    • Compulsory Request Parameters
      • id: [integer: Node id]
      • owner: [string: Updated node owner/description]
    • Return Parameters
      • error: [integer: '0' for successful, otherwise error]
  • /checkNodeId - GET
    • Checks if a node callsign is available
    • Compulsory Request Parameters
      • id: [string: Proposed node callsign]
    • Return Parameters
      • error: [integer: '1' for available, '0' for not]

Field IDs

ID Type
1 Temperature
2 Voltage
3 RSSI
4 Pressure
5 Humidity
6 Location
7 Sun
api.txt · Last modified: 2016/03/10 12:38 by craag