4 releases

0.1.1 Dec 6, 2022
0.1.0 Nov 11, 2022
0.0.2 Jan 18, 2022
0.0.1 Jan 18, 2022

#114 in #requests

MIT license

38KB
658 lines

Yupdates Rust SDK

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

This is hosted on GitHub. There is also a Yupdates Python SDK.

Overview

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.

Getting started

First, obtain an API token from the application. Navigate to "Settings" and then "API".

The examples will start with read-only operations, so you can use the general, read-only token to get started.

Create a new Rust project:

$ cargo new yupdates-example
$ cd yupdates-example

Add the dependency to Cargo.toml:

[dependencies]
yupdates = "0"

Add this to the src/main.rs file:

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

fn main() -> Result<(), Error> {
    let yup = new_sync_client()?;
    let response = yup.ping()?;
    println!("Ping worked: {}", response.message);
    Ok(())
}

Set the API token environment variable (use a different value, this example will not work):

set +o history
export YUPDATES_API_TOKEN="789a4e8703:78b15453350458054b84443819060b1a213382cc697a5"
set -o history

Test the connection and authentication:

cargo run

Once that is working, you can make other calls. For example, to read the latest 10 items from a feed:

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);
    }
    Ok(())
}

There are more examples in the tests and code documentation. You can see the tests on GitHub, and see the code documentation on docs.rs.

Getting help

You can create a GitHub issue on this repository for bugs and feature requests.

The fastest way to get help is to create a support ticket from the Yupdates application. Or email support@yupdates.com. Especially if you need help that is not specific to this SDK, or if you would like more hands-on setup and troubleshooting advice.

License

The SDK is distributed under the MIT license, please see LICENSE for more information.

This covers the source code and examples, but it does not cover related items like the Yupdates logo or API documentation which is not hosted here.

Dependencies

~6–18MB
~247K SLoC