Crate yupdates

source ·
Expand description

Yupdates Rust SDK

The Yupdates Rust SDK lets you easily use the Yupdates API from your own software and scripts.

The code is hosted on GitHub. Also see the Yupdates Python SDK.

The api module provides a low-level functions that wrap calls to the HTTP+JSON API, serializing and deserializing the requests and responses.

The clients module provides an async client that is more convenient, and clients::sync provides a synchronous version of the client that hides any need to set up an async runtime.

The following examples require setting the YUPDATES_API_TOKEN environment variable.

Synchronous client example:

use yupdates::api::YupdatesV0;
use yupdates::clients::sync::new_sync_client;
use yupdates::errors::Error;

fn main() -> Result<(), Error> {
    let feed_id = "02fb24a4478462a4491067224b66d9a8b2338ddca2737";
    let yup = new_sync_client()?;
    for item in yup.read_items(feed_id)? {
        println!("Title: {}", item.title);

The following asynchronous client example requires adding tokio to your Cargo.toml. For example: tokio = { version = "1", features = ["macros"] }

use yupdates::clients::new_async_client;
use yupdates::errors::Error;

async fn main() -> Result<(), Error> {
    let feed_id = "02fb24a4478462a4491067224b66d9a8b2338ddca2737";
    let yup = new_async_client()?;
    for item in yup.read_items(feed_id).await? {
        println!("Title: {}", item.title);

See the README. The SDK is distributed under the MIT license, see LICENSE.


Functions to interact with the API directly (typically, you would use the client wrappers found in the crate::clients module)
Wrappers that allow you set up the configurations once and then make many calls
Error and result types
Clean structs for API objects, marshalled to and from JSON via serde


The HTTP header we need on every API call
Environment variable to consult for the API token (you can bypass this by passing the token directly to certain functions)
Environment variable to consult for the base API URL. It’s not usually needed: you would typically only use this to exercise against an alternative API endpoint, or if you wanted to downgrade API versions in the future (right now, there is only /api/v0/).
The default base URL


Retrieve the API token from the environment.
Retrieve the API URL from the environment or use the default.
Accept many forms of item time, validate it, and return a normalized version.
This is normalize_item_time for when you are using integer timestamps.