Hello there,
today, I finally published the package satnogs-api-client on pypi and crates.io. satnogs-api-client aims to provide a convenient rusty and pythonic abstraction of the satnogs-netwok API. It is OpenSource and licensed under AGPL-3.0-only.
Motivation
This client is mainly a byproduct of my still ongoing effort to reimplement the satnogs-client in Rust (with some other architectural decisions and more hackable), which lead me to implement this tiny api client too. It encapsulates most of the functionality a satnogs-client needs. This includes also the upload of artifacts (which needed a tiny bit of research).
Once the rust-implementation was there, I felt there should be a python-interface using the maturin crate too. So the functions implemented in this client are also usable from a python-interpreter. I like this combination pretty much for that Python is very elegant and simple in usage, while Rust provides type safety and performance for heavy lifting.
Examples for Python
You can install the package from pypi:
$ pip install satnogs-api-client
and run different examples. This one fetches a specific observation and prints different information on it:
from satnogs_api_client import APIClient
c = APIClient("https://network.satnogs.org/api")
ob = c.get_observation(13341257)
print("ID: ", ob.id)
print("GS: ", ob.ground_station)
print("Status: ", ob.status)
print("Packets:", len(ob.demoddata))
print("TLE: ", ob.tle0)
print("TLE: ", ob.tle1)
print("TLE: ", ob.tle2)
gives:
ID: 13341257
GS: 1860
Status: good
Packets: 1066
TLE: 0 CROCUBE
TLE: 1 62394U 24247T 26036.99781543 .00044088 00000-0 11195-2 0 9999
TLE: 2 62394 44.9735 273.7889 0002212 191.4907 168.5929 15.39013829 63077
With the power of python scripting, also other stuff is possible. E.g. this example deletes future observations scheduled by a specific user (should be used against abuse only!):
from datetime import UTC, datetime
from time import sleep
from satnogs_api_client import APIClient, ObservationFilter
token = "__my_api_token__"
api = APIClient("https://network.satnogs.org/api", token)
f = ObservationFilter(ground_station=2519, end__gt=datetime.now(tz=UTC))
jobs = api.get_observations(f)
for j in jobs:
if j.observer == "some_user_name":
print(f"deleting {j.id}...")
api.delete_job(j.id)
sleep(1) # throttling for API
Feel free to hack your own scripts with this. ![]()
Examples for Rust
You can get this crate from crates.io and codeberg.org:
$ cargo add satnogs_api_client
You can find different examples in the examples-folder.
This example lists all stations currently online:
use std::time::Duration;
use ureq::Agent;
use satnogs_api_client::api_client::APIClient;
use satnogs_api_client::filters::StationFilter;
static SATNOGS_NETWORK_URL: &str = "https://network.satnogs.org/api/";
fn main() {
let config = Agent::config_builder()
.timeout_global(Some(Duration::from_secs(60)));
let api = APIClient::new(config, SATNOGS_NETWORK_URL.to_string(), None);
let f = StationFilter{ status: Some("online".to_string()), name: None, client_version: None };
let stations = api.get_stations(f).unwrap();
println!("{} stations online.\n", stations.len());
for s in stations {
println!("{}\t{}", s.id, s.name)
}
}
gives:
306 stations online.
26 SV1IYO/A
34 M0SZT
37 DL4PD
39 CGBSAT-VHF
40 CGBSAT-UHF
77 N5CNB-VHF
85 Alfeld
91 M0EYT
98 Grove-UHF-01
106 BEEGND-1
158 VK6SAT - UHF
167 G7ODQ-pi
168 SM0IFP
I hope you can enjoy this as much as I do. I will take this crate as a foundation of commencing my
satnogs-journey with more rust code.
Best wishes to you all,
mhuebner