Crates.io | sparql-client |
lib.rs | sparql-client |
version | 0.1.0 |
source | src |
created_at | 2024-09-20 23:11:01.176058 |
updated_at | 2024-09-20 23:11:01.176058 |
description | SPARQL client based on Oxigraph components |
homepage | https://agora.nasqueron.org/Nasqueron_Datasources |
repository | https://devcentral.nasqueron.org/source/datasources/browse/main/sparql-client/ |
max_upload_size | |
id | 1381847 |
size | 10,005 |
The crate sparql-client is a SPARQL client based on Oxigraph components.
It can be used to query SPARQL endpoints like Wikidata.
use sparql_client::Client;
#[tokio::main]
async fn main() {
let client = Client::new("https://query.wikidata.org/sparql");
let railway_query = r#"
#Cities connected by the Trans-Mongolian and Trans-Siberian Railway
SELECT ?city ?cityLabel ?coordinates
WHERE
{
VALUES ?highway { wd:Q559037 wd:Q58767 }
?highway wdt:P2789 ?city .
?city wdt:P625 ?coordinates .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
"#;
let solutions = client
.query(railway_query).await
.into_solutions()
.expect("No response has been found for the query.");
for city_solution in solutions {
println!("{:?}", city_solution);
}
}