#buy #api #coffee #membership #api-bindings #email #page

buy_me_a_coffee

A Rust crate for interacting with the Buy Me a Coffee API

4 releases (2 breaking)

0.3.1 Nov 15, 2024
0.3.0 Nov 15, 2024
0.2.0 Nov 14, 2024
0.1.0 Oct 31, 2024

#769 in Web programming

Download history 126/week @ 2024-10-28 20/week @ 2024-11-04 314/week @ 2024-11-11 56/week @ 2024-11-18 5/week @ 2024-11-25 10/week @ 2024-12-09

91 downloads per month

MIT license

14KB
256 lines

buy_me_a_coffee

Crates.io Version docs.rs Rust

A Rust crate for interacting with the Buy Me a Coffee API.

Here's an example of how you could use this crate to check if somebody has a membership level called "Early Access":

use buy_me_a_coffee::MemberStatus;

async fn has_early_access(email: String) -> bool {
    let client = buy_me_a_coffee::Client::new("personal access token here");
    let mut page_num = 1;

    while let Ok(page) = client.members(MemberStatus::Active, page_num).await {
        for membership in page.data {
            if membership.payer_email != email {
                continue;
            }

            if membership.id != EARLY_ACCESS_ID {
                continue;
            }

            return true;
        }

        page_num += 1;
    }

    false
}

Truthfully, this crate is not really ready to be used. It's not possible to test most things when I don't have any supporters on Buy Me a Coffee since the API returns a "No [subscriptions|supporters|extra purchases]" error. If someone would buy me a coffee, that would really help out with this project, wink wink...

Dependencies

~4–15MB
~198K SLoC