| Crates.io | vizier-adql |
| lib.rs | vizier-adql |
| version | 0.2.0 |
| created_at | 2024-04-23 18:05:25.546342+00 |
| updated_at | 2024-04-28 16:07:32.622064+00 |
| description | Simple Rust client for querying astronomical data from VizieR using ADQL |
| homepage | |
| repository | https://github.com/mclrc/vizier-rs |
| max_upload_size | |
| id | 1217840 |
| size | 9,572 |
Allows easy, type-safe access to VizieR TAP APIs to query a wide variety of astronomical catalogues using ADQL.
Run $ cargo add vizier-adql, or add vizier-adql = "0.2.0" to Cargo.toml under [dependencies].
use vizier_adql::Client;
use serde_json::Value;
// 1. Create a client
let client = Client::default();
// 2. Execute queries
let objects = client
.query::<Value>("SELECT TOP 100 * FROM \"I/261/fonac\"")
.await
.unwrap()
.data();
// ...
Client::default() will use http://tapvizier.u-strasbg.fr/TAPVizieR/tap/sync as the TAP endpoint. If you need to specify a different endpoint, use Client::new("your_endpoint_url").
The VizieR column metadata is also available on the result via QueryResult::meta.
If you don't want to use async, enable the is_sync feature on the crate. The API won't change, except that Client::query now blocks and returns the value directly.
To strictly parse the response, create a struct resembling an element from the response and derive Deserialize for it.
#[derive(Deserialize)]
struct CatalogObject {
AC2000: i32,
ACT: Option<i32>,
#[serde(rename = "B-R")]
BR: Option<f64>,
#[serde(rename = "B-V")]
BV: Option<f64>,
Bmag: f64,
DEJ2000: f64,
#[serde(rename = "Ep-1900")]
Ep1900: f64,
Qflag: Option<i32>,
RAJ2000: f64,
pmDE: f64,
pmRA: f64,
q_Bmag: Option<i32>,
recno: i32,
}
Then, query and parse like so:
let objects = client
.query::<CatalogObject>("SELECT TOP 100 * FROM \"I/261/fonac\"")
.await
.unwrap()
.data()
// ...