A lightweight SpaceAPI server with both web and REST interfaces.
  • TypeScript 99.4%
  • Dockerfile 0.6%
Find a file
2025-05-29 08:02:23 +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
.dockerignore docker: initial commit 2025-05-29 08:02:23 +02:00
.env.example Initial commit from Strapi 2025-03-22 02:44:46 +01:00
.gitignore Update .gitignore 2025-05-29 08:01:47 +02:00
.prettierrc.json Add Prettier config 2025-05-23 00:45:22 +02:00
docker-compose.yml docker: initial commit 2025-05-29 08:02:23 +02:00
Dockerfile docker: initial commit 2025-05-29 08:02:23 +02:00
favicon.png Initial commit from Strapi 2025-03-22 02:44:46 +01:00
LICENSE Create LICENSE 2025-05-28 23:38:06 +02: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 23:18:49 +02:00
tsconfig.json Initial commit from Strapi 2025-03-22 02:44:46 +01:00

Simple SpaceAPI

A lightweight SpaceAPI server with both web and REST interfaces.

Built with Node.js and 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 endpoint data can be added or modified via the admin panel or through the REST API.

To list all available API endpoints, use the Strapi CLI:

npm run strapi routes:list

API Tokens

To update data, you need an API token.
Tokens can be generated and managed in the admin panel, under Settings → API Tokens.
You can also define token-specific permissions there.

For more details, see the Strapi API Tokens Documentation.

Examples

Some example requests using the HTTPie CLI:

Get the Main SpaceAPI Endpoint Info

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 a Sensor

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

Timestamps

Simple SpaceAPI does not attempt to be smart about timestamps, so any successful request will update the corresponding lastchange field.

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

Validation

While Simple SpaceAPI performs basic data validation, it's still possible to produce invalid SpaceAPI JSON.

Always validate your endpoint using the SpaceAPI Validator.

Units

Due to some Strapi limitations, certain sensor units must be replaced with aliases in API requests:

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

The main SpaceAPI endpoint will display the correct units.

Sensor Structure

While Simple SpaceAPI follows the general SpaceAPI format, the internal structure of some sensors is simplified:

  • Radiation sensors (alpha, beta, gamma, beta_gamma) are unified into a single radiation type. The exact subtype can be specified using the type field.

Deployment

Coming soon.

Resources

SpaceAPI

Strapi