Skip to content

snipp-gg/snipp-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snipp-rust

A Rust wrapper for the Snipp API.

Features

  • Async/await with Tokio runtime
  • Built on reqwest with full type safety
  • Rich error handling with SnippError

Requirements

Installation

Add to your Cargo.toml:

[dependencies]
snipp = "0.1"
tokio = { version = "1", features = ["full"] }

Quick Start

use snipp::{SnippClient, GetUserOptions, Privacy};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = SnippClient::new("YOUR_API_KEY");

    // Get the authenticated user
    let me = client.get_user("@me", None).await?;
    println!("{}", me.user.username.unwrap_or_default());

    // Upload a file
    let upload = client.upload("./screenshot.png", Some(Privacy::Unlisted)).await?;
    println!("Uploaded: {}", upload.url.unwrap_or_default());

    // List recent uploads
    let uploads = client.list_uploads().await?;

    // Delete an upload
    client.delete_upload("a3f7b2c91d4e8f0612ab34cd56ef7890.png").await?;

    // Browse public uploads
    let discover = client.discover().await?;

    Ok(())
}

API

All methods are async and return Result<T, SnippError>.

SnippClient::new(api_key)

Create a client. The key is sent via the api-key header on every request.

get_user(id, options)

Get a user by ID. Pass "@me" for the authenticated user.

Option Type Description
include_posts Option<bool> Include the user's public uploads.
posts_limit Option<u32> Number of posts to return (1-50).
let opts = GetUserOptions {
    include_posts: Some(true),
    posts_limit: Some(10),
};
let user = client.get_user("some-user-id", Some(opts)).await?;

upload(path, privacy)

Upload a file from a path. Privacy: Public, Unlisted, or Private.

let result = client.upload("./image.png", Some(Privacy::Unlisted)).await?;

list_uploads()

List the authenticated user's recent uploads. Each upload entry includes the file URL, size metadata, optional post code, and is_album when the upload belongs to an album post.

delete_upload(filename)

Delete an upload by its filename.

discover()

Browse public uploads.

Error Handling

SnippError covers HTTP errors, API errors (non-2xx responses), deserialization failures, and IO errors during file uploads.

Contributing

We welcome suggestions and improvements:

License

MIT License © 2026 Snipp. See LICENSE for full details.

About

Rust API wrapper for Snipp.

Resources

License

Stars

Watchers

Forks

Contributors

Languages