Skip to main content
snipp-gg/snipp-py
snipp

Installation

Requires Python 3.9 or later. Depends on requests.

Getting Started

Regional Endpoints

Pass region to pin the client to a specific regional host. Uploads run at the same speed either way; this controls which region stores your files.

Methods

Every method returns the parsed JSON response as a dict. Posts, files, and users follow the shapes in the API reference, and the package exports matching TypedDict classes (Post, PostFile, User, PostList, and the rest) for editor completion.

get_user(user_id="@me")

Fetch a user by ID. Pass "@me" or omit it for the authenticated user. api_key, key_has_uploads_access, upload_count, and limits are only present on yourself.

get_user_posts(user_id, limit=None, cursor=None)

List a user’s public posts, newest first. Team, private, unlisted, moderated, and restricted posts are never included. Pass "@me" for your own public posts.

list_posts(limit=None, cursor=None)

List your own posts of every privacy, newest first. Team posts are not included. Takes the same limit and cursor as get_user_posts. Follow next_cursor until it is None to walk every page.

get_post(code)

Fetch a post by its share code. Team posts are only readable by members of that team, and have like_count and liked set to None.

upload(file, privacy=None, title=None, description=None, post_type=None, include_metadata=None, priority=None)

Upload a file as a new post. Accepts a file path string, bytes, or a file-like object. Returns url (the direct file URL) and post, whose url is the share page, https://snipp.gg/p/{code} or https://{domain}/{code} on your link domain. A file of 100 MiB or more is sent in 50 MiB pieces, 3 at a time, each retried on its own, and the call returns once the server has finished processing it, so file size is limited only by your plan’s per-file limit, limits.max_file_size. A file path is read one piece at a time instead of loaded into memory. A file object that cannot seek is always sent in one request.

update_post(code, title=None, description=None, privacy=None)

Update a post’s title, description, or privacy. Only the arguments you pass are changed. A team post’s privacy cannot be changed. Returns post.

add_files(code, files, include_metadata=None, priority=None)

Add one or more files to an existing post, turning it into an album. The post’s share code, privacy, title, and description are preserved. A post holds up to 10 files on Free and 50 on Plus, with no limit on Ultra and in a team. Requests that would exceed the cap are rejected. New files inherit the post’s privacy. Returns post, plus failed when some files were rejected, each with its index and error. Files under 100 MiB go in one request; each file of 100 MiB or more is then sent on its own in 50 MiB pieces, as in upload(). If one of those fails, the call raises and the files added before it stay.

delete_file(code, name)

Delete one file from a post, by the name it has in post["files"]. Deleting a post’s only file deletes the post.

delete_post(code)

Delete a post and every file in it.

report_post(code, reason=None)

Report a post, with an optional reason (max 200 chars).

report_user(user_id, reason=None)

Report a user, with an optional reason (max 200 chars).

Error Handling

All API errors raise a SnippError with these attributes:

Migrating from 2.x

3.0 follows the reorganized Snipp API.
  • Posts use one shape everywhere: privacy (was post_privacy), created_at (was created), view_count (was views), files[].name (was file_name), and file_count replaces is_album. The top-level urls, file, and thumbnail_url are gone; read files.
  • upload() returns url and post; message, file, and processing_time are gone.
  • Users carry plan (free, plus, or ultra) in place of plus, ultra, and badges, created_at in place of created, and blocking in place of blocked_by_you.
  • The API now sends every error as an error object with type, message, and any context fields. SnippError gains type, message falls back to the HTTP status text instead of the raw response body, and context fields moved from the top of body into body["error"]. A check like err.body.get("suspended") becomes err.type == "suspended".