Crate aletheia

source ·
Expand description

Aletheia is a client library for the Guardian’s content API.

It is built on top of reqwest and provides a similar interface for building queries. Responses returned by the client are deserialized into structs, mirroring the types used by the API.

Keys to start querying the API can be obtained here: https://open-platform.theguardian.com/access/

More information on the API can be found here: https://open-platform.theguardian.com/documentation/

Example

use std::error::Error;
use aletheia::{GuardianContentClient, Result};
use aletheia::enums::{Field, OrderBy, OrderDate};

#[tokio::main]
async fn main() -> Result<()> {
    let mut client = GuardianContentClient::new("your-api-key");

    let response = client
        .search("Elections")
        .page_size(10)
        .show_fields(vec![Field::Byline, Field::LastModified])
        .order_by(OrderBy::Newest)
        .order_date(OrderDate::Published)
        .send()
        .await?;

    let results = response.results;

    Ok(())
}

Modules

Enum types that prevent passing illegal parameters to the Guardian’s content API.
Error variants.
Structs for deserializing the Guardian’s content API responses.

Structs

The main asynchronous client used to build requests to send to the Guardian’s content API. This client maintains a private internal asynchronous client implemented by reqwest::Client

Type Definitions

A wrapper around Rust’s core::result::Result<T, E> which defaults to aletheia’s own Error type.