snipp-gg/snipp-js
@snipp-gg/snipp
Installation
fetch and FormData.
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
getUser(id, options?)
Fetch a user by ID. Pass "@me" for the authenticated user.
getPost(code)
Fetch a post by its share code. Team posts are only readable by members of that team, and omit likeCount.
upload(file, options?)
Upload a file. Accepts a File, Blob, Buffer, or Uint8Array.
listUploads(options?)
List the authenticated user’s recent uploads. Defaults to 30. Pass limit to control the count (max 1000).
editUpload(code, options)
Edit an existing upload’s title, description, or privacy.
appendUpload(code, files, options?)
Add one or more files to an existing album post. The post’s share code, privacy, title, and description are preserved. Albums cap at 50 files total. Requests that would exceed the cap are rejected. New files inherit the post’s privacy. Returned URLs are signed with a 24-hour expiry for private posts.
deleteUpload(filename)
Delete an upload by its filename. On albums, only that file is removed; on single-file posts the entire post is deleted.
reportPost(code, reason?)
Report a post, with an optional reason (max 200 chars).
Error Handling
All API errors throw aSnippError with status, message, and body properties. body is the parsed JSON error response, or null when the response was not JSON. It carries the fields the API sends alongside error, such as suspended on a suspended user or moderated on a moderated post.