| Crates.io | rsxiv |
| lib.rs | rsxiv |
| version | 0.4.0 |
| created_at | 2025-08-22 14:28:21.688341+00 |
| updated_at | 2025-08-31 23:31:03.541873+00 |
| description | Tools for working with arXiv and the arXiv API |
| homepage | |
| repository | https://github.com/autobib/rsxiv |
| max_upload_size | |
| id | 1806437 |
| size | 266,758 |
A Rust library to provide an interface for arXiv identifiers and the arXiv API.
Key features:
This crate will not make the network request itself. For that, you might use ureq or reqwest.
Example using ureq:
use std::{borrow::Cow, collections::BTreeMap};
use rsxiv::{
ArticleId, Query, Response,
query::{Combine, Field, FieldGroup, SortBy, SortOrder},
response::AuthorName,
};
use serde::Deserialize;
use ureq;
#[derive(Deserialize)]
struct Entry<'r> {
// Built-in author name parsing
authors: Vec<AuthorName>,
title: Cow<'r, str>,
}
fn main() -> anyhow::Result<()> {
let mut query = Query::new();
query
// sort the results
.sort(SortBy::SubmittedDate, SortOrder::Ascending)
// access handle to the search query
.search_query()
// require title matching 'proton'
.init(Field::ti("Proton").unwrap())
// and require author `Bob`, or author `John`
.and(FieldGroup::init(Field::au("Bob").unwrap()).or(Field::au("John").unwrap()));
// make the request using `ureq`
let response_body = ureq::get(query.url().as_ref())
.call()?
.into_body()
.read_to_vec()?;
// deserialize API response
let response = Response::<BTreeMap<ArticleId, Entry>>::from_xml(&response_body)?;
// sort by year, month, archive, number, version
for (id, entry) in response.entries.iter() {
println!(
"'{}' by {}{} [{id}]",
entry.title,
entry.authors[0],
if entry.authors.len() > 1 {
" et al."
} else {
""
}
);
}
Ok(())
}