snipp-gg/snipp-py
snipp
Installation
requests.
Getting Started
Regional endpoints
Passregion 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 adict. 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.
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. Posts cap at 50 files total. 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.
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 aSnippError with these attributes:
Migrating from 2.x
3.0 follows the reorganized Snipp API.- Posts use one shape everywhere:
privacy(waspost_privacy),created_at(wascreated),view_count(wasviews),files[].name(wasfile_name), andfile_countreplacesis_album. The top-levelurls,file, andthumbnail_urlare gone; readfiles. upload()returnsurlandpost;message,file, andprocessing_timeare gone.- Users carry
plan(free,plus, orultra) in place ofplus,ultra, andbadges,created_atin place ofcreated, andblockingin place ofblocked_by_you. - The API now sends every error as an
errorobject withtype,message, and any context fields.SnippErrorgainstype,messagefalls back to the HTTP status text instead of the raw response body, and context fields moved from the top ofbodyintobody["error"]. A check likeerr.body.get("suspended")becomeserr.type == "suspended".