Skip to main content

snipp-gg/snipp

snipp

Installation

pip install snipp
Requires Python 3.9 or later. Depends on requests.

Getting started

from snipp import SnippClient

client = SnippClient(api_key="YOUR_API_KEY")

me = client.get_user("@me")
print(me["user"]["username"])

Methods

get_user(user_id, include_posts=None, posts_limit=None)

Fetch a user by ID. Pass "@me" for the authenticated user.
ParameterTypeDescription
user_idstrUser ID or "@me".
include_postsbool | NoneInclude the user’s public uploads.
posts_limitint | NoneNumber of posts to return (1-50).
user = client.get_user("@me", include_posts=True, posts_limit=10)

get_post(code)

Fetch a post by its share code.
ParameterTypeDescription
codestrThe share code of the post.
post = client.get_post("AbCd1234")
print(post["post"]["url"])

upload(file, privacy="unlisted")

Upload a file. Accepts a file path string, bytes, or a file-like object.
ParameterTypeDescription
filestr | bytes | BinaryIOFile path, raw bytes, or file object.
privacystr"public", "unlisted", or "private".
result = client.upload("image.png", privacy="unlisted")
print(result["url"])

list_uploads()

List the authenticated user’s recent uploads.
uploads = client.list_uploads()

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

Edit an existing upload’s title, description, or privacy.
ParameterTypeDescription
codestrThe share code of the upload.
titlestr | NoneNew title (max 30 chars). Empty string to clear.
descriptionstr | NoneNew description (max 200 chars). Empty string to clear.
privacystr | None"public", "unlisted", or "private".
client.edit_upload("AbCd1234", title="New title", privacy="public")

delete_upload(filename)

Delete an upload by its filename.
client.delete_upload("a3f7b2c91d4e8f0612ab34cd56ef7890.png")

discover()

Browse public uploads from the community.
feed = client.discover()

list_blocks()

List the users you have blocked.
blocks = client.list_blocks()

block_user(target_id)

Block a user by their ID.
client.block_user("123456789012345678")

unblock_user(target_id)

Unblock a user by their ID.
client.unblock_user("123456789012345678")

Error handling

All API errors raise a SnippError with status and message attributes.
from snipp import SnippClient, SnippError

try:
    client.get_user("nonexistent")
except SnippError as err:
    print(err.status, err.message)