A lightweight SpaceAPI server with both web and REST interfaces.
  • TypeScript 99.4%
  • Dockerfile 0.6%
Find a file
2025-05-28 21:15:48 +02:00
config config: disable ads 2025-03-27 09:47:26 +01:00
database/migrations Initial commit from Strapi 2025-03-22 02:44:46 +01:00
docs/images docs: rename the screenshot 2025-05-28 21:13:53 +02:00
public Initial commit from Strapi 2025-03-22 02:44:46 +01:00
src checkhealth: add dummy endpoint 2025-05-23 16:33:34 +02:00
types/generated SpaceAPI: sensors: radiation: required fields 2025-05-23 02:20:49 +02:00
.env.example Initial commit from Strapi 2025-03-22 02:44:46 +01:00
.gitignore Initial commit from Strapi 2025-03-22 02:44:46 +01:00
.prettierrc.json Add Prettier config 2025-05-23 00:45:22 +02:00
favicon.png Initial commit from Strapi 2025-03-22 02:44:46 +01:00
package-lock.json package.json: rename the project 2025-05-28 20:58:59 +02:00
package.json package.json: rename the project 2025-05-28 20:58:59 +02:00
README.md Update README.md 2025-05-28 21:15:48 +02:00
tsconfig.json Initial commit from Strapi 2025-03-22 02:44:46 +01:00

Simple SpaceAPI

A simple SpaceAPI server with web and REST interfaces.

Built with Node.js using Strapi.

Screenshot

Quick Start

Install dependencies and start the server in development mode:

npm install
npm run develop

Most files are autogenerated.
The main entry point is ./src/api/spaceapi/controllers/spaceapi.ts.

Usage

All the data for your endpoint could be added and modified with the admin panel or with the REST API.

You could use the Strapi CLI to list all availible API endpoints:

npm run strapi routes:list

API Tokens

To update the data you need to obtain the API token.
You could define token's specific permissions in the admin panel.

For additional details see Strapi Tokens Documentation.

Examples

Some HTTPIe CLI requests here:

Main SpaceAPI Endpoint

http GET http://localhost:1337/api/spaceapi

Update the Hackspace State

API_TOKEN=your-token-here
http PUT \
  http://localhost:1337/api/state \
  Authorization:"Bearer $API_TOKEN" \
  data:='{
    "open": true,
    "trigger_person": "Owner",
    "message": "We are open!"
  }'

Update the Sensors

API_TOKEN=your-token-here

# Discover the documentId for the sensor
http GET \
  http://localhost:1337/api/temperature-sensors \
  Authorization:"Bearer $API_TOKEN"

DOCUMENT_ID=nrfn2800pexpwxuhqikzr7xa

http PUT \
  http://localhost:1337/api/temperature-sensors/$DOCUMENT_ID \
  Authorization:"Bearer $API_TOKEN" \
  data:='{
    "unit": "°C",
    "value": 25
  }'

Caveats

Lastchange

Simple SpaceAPI not trying to be smart about timespamps so any successful update will affect this field.

For example if you set the hackspace state to "closed" and repeat the same request next day then lastchange will be overrided.

Validation

While Simple SpaceAPI is trying to validate the data it's still possible to generate invalid SpaceAPI JSON.

Do not forget to check your endpoint with the SpaceAPI Validator.

Units

Due to the some Strapi limitations several sensor units should be replaced with aliases for API requests:

  • Humidity Sensor: use percents instead of %;
  • Wind Sensor: use degree instead of °;

Main SpaceAPI endpoint will show correct units.

Shape of Sensors

While Simple SpaceAPI is trying to follow the SpaceAPI structure, some sensors shape is simplified:

  • Nested alpha, beta, gamma and beta_gamma radiation sensors were unified as generic radiation. Type of the sensor could be specified with type field.

Deployment

TBD

Resources