Skip to content

Get started with REST API

dernasherbrezon edited this page Feb 20, 2024 · 2 revisions

r2cloud can be controlled via REST API programmatically. Full API reference is available under "API" menu. Please note, that all requests below have "-k" option to accept self-signed certificates. This certificate is generated upon installation and unique for each station. It is generally safe to use it. However if you want further security, then the station should have proper domain name and valid certificate. Such certificate can be automatically issued by LetsEncrypt.

Authenticate

r2cloud uses token-based authentication.

curl -k -X POST -H "Content-Type: application/json" -d '{"username": "username", "password": "password"}' https://localhost/api/v1/accessToken 

It should return JSON with access token:

{"access_token":"4909187dbe0783c41b4ae3a6","token_type":"bearer","expires_in":1800}

This access token should be used in further requests

Getting all observations

Getting the list of currently running observations and all past observations can be done using the following command:

curl -k -X GET -H "Authorization: Bearer 4909187dbe0783c41b4ae3a6" https://localhost/api/v1/admin/observation/list 

The result will be JSON:

[
	{
		"id": "1708429050290-52898-0",
		"satelliteId": "52898",
		"name": "RANDEV",
		"start": 1708429050290,
		"end": 1708429822140,
		"status": "RECEIVING_DATA",
		"hasData": false
	},
	{
		"id": "1708427573242-52739-0",
		"satelliteId": "52739",
		"name": "CONNECTA T1.1",
		"start": 1708427868580,
		"end": 1708428231363,
		"status": "UPLOADED",
		"numberOfDecodedPackets": 0,
		"hasData": false
	}
]

All field descriptions can be found in the API reference under "API" menu.

Clone this wiki locally