REST API Reference
SnipShare exposes a complete REST API under the snipshare/v1 namespace. All endpoints are accessible at /wp-json/snipshare/v1/.
Authentication
Section titled “Authentication”| Method | Use Case |
|---|---|
| WP Cookie + X-WP-Nonce header | Logged-in users on the frontend. Get nonce via wp_rest_nonce() or wpApiSettings.nonce. |
| Application Passwords | External apps, mobile clients, CLI tools. Create at WP Admin → Users → Edit User → Application Passwords. |
Public endpoints (reading public pastes, tags, oEmbed) require no authentication.
Global Parameters
Section titled “Global Parameters”All list endpoints support these query parameters:
| Parameter | Description |
|---|---|
page |
Page number (default: 1) |
per_page |
Results per page (default: 10, max: 100) |
orderby |
Sort field (e.g., created_at, star_count, view_count) |
order |
asc or desc (default: desc) |
_fields |
Comma-separated list of fields to include in response (sparse fieldsets) |
_embed |
Include linked resources inline (author, files) |
Pagination response headers: X-WP-Total (total items), X-WP-TotalPages (total pages).
Pastes
Section titled “Pastes”List Pastes
Section titled “List Pastes”GET /wp-json/snipshare/v1/pastesReturns public pastes. Supports additional filter params:
| Param | Description |
|---|---|
language |
Filter by language slug |
user |
Filter by WP user ID or username |
tag |
Filter by tag slug |
search |
Full-text search on title and description |
status |
active (default) |
Create Paste
Section titled “Create Paste”POST /wp-json/snipshare/v1/pastesAuth required. Request body (JSON):
{ "title": "My helper", "description": "Useful PHP utility", "visibility": "public", "expiration": "never", "password": "", "burn_after_read": false, "tags": ["php", "utilities"], "files": [ { "filename": "helper.php", "content": "<?php function foo() {}", "language": "php" } ]}Get Paste
Section titled “Get Paste”GET /wp-json/snipshare/v1/pastes/{id}Public for public/unlisted pastes. Requires auth for private pastes (owner only).
Update Paste
Section titled “Update Paste”PUT /wp-json/snipshare/v1/pastes/{id}Owner or moderator only. Same body shape as create. Each changed file generates a revision.
Delete Paste (Trash)
Section titled “Delete Paste (Trash)”DELETE /wp-json/snipshare/v1/pastes/{id}Owner or moderator only. Sets status to trashed.
Fork Paste
Section titled “Fork Paste”POST /wp-json/snipshare/v1/pastes/{id}/forkAuth required. Clones all files into a new paste. Returns the new paste object.
Toggle Star
Section titled “Toggle Star”POST /wp-json/snipshare/v1/pastes/{id}/starAuth required. Toggles star on/off. Response: { "starred": bool, "star_count": int }.
Report Paste
Section titled “Report Paste”POST /wp-json/snipshare/v1/pastes/{id}/reportAuth required. Body: { "reason": "spam|inappropriate|malicious|copyright|other", "details": "optional text" }.
Unlock Password-Protected Paste
Section titled “Unlock Password-Protected Paste”POST /wp-json/snipshare/v1/pastes/{id}/unlockBody: { "password": "secret" }. Stores unlock in session. Returns 200 on success, 403 on wrong password.
List Revisions
Section titled “List Revisions”GET /wp-json/snipshare/v1/pastes/{id}/revisionsOwner/moderator for private pastes, public for public/unlisted.
Get Diff
Section titled “Get Diff”GET /wp-json/snipshare/v1/pastes/{id}/diff?from=1&to=3Returns structured diff data per file.
Raw Content
Section titled “Raw Content”GET /wp-json/snipshare/v1/pastes/{id}/rawGET /wp-json/snipshare/v1/pastes/{id}/raw/{file_id}Returns plain text. The /raw/{file_id} variant returns a single file’s content.
Download
Section titled “Download”GET /wp-json/snipshare/v1/pastes/{id}/downloadReturns single file or ZIP archive download.
Add File to Paste
Section titled “Add File to Paste”POST /wp-json/snipshare/v1/pastes/{id}/filesOwner only. Body: { "filename": "...", "content": "...", "language": "..." }.
Update File
Section titled “Update File”PUT /wp-json/snipshare/v1/pastes/{id}/files/{fid}Owner only. Body: any subset of filename, content, language.
Delete File
Section titled “Delete File”DELETE /wp-json/snipshare/v1/pastes/{id}/files/{fid}Owner only. Paste must retain at least one file.
Collections
Section titled “Collections”List My Collections
Section titled “List My Collections”GET /wp-json/snipshare/v1/collectionsAuth required. Returns the current user’s collections.
Create Collection
Section titled “Create Collection”POST /wp-json/snipshare/v1/collectionsBody: { "name": "...", "slug": "...", "description": "...", "visibility": "public|private" }.
Get Collection
Section titled “Get Collection”GET /wp-json/snipshare/v1/collections/{id}Owner for private, public for public collections.
Update Collection
Section titled “Update Collection”PUT /wp-json/snipshare/v1/collections/{id}Owner only. Updatable fields: name, description, visibility.
Delete Collection
Section titled “Delete Collection”DELETE /wp-json/snipshare/v1/collections/{id}Owner only. Pastes are not affected.
Add Paste to Collection
Section titled “Add Paste to Collection”POST /wp-json/snipshare/v1/collections/{id}/pastesBody: { "paste_id": 42 }.
Remove Paste from Collection
Section titled “Remove Paste from Collection”DELETE /wp-json/snipshare/v1/collections/{id}/pastes/{paste_id}List All Tags
Section titled “List All Tags”GET /wp-json/snipshare/v1/tagsPublic. Returns tags sorted by count descending.
List Pastes by Tag
Section titled “List Pastes by Tag”GET /wp-json/snipshare/v1/tags/{slug}/pastesPublic. Returns public pastes with this tag. Supports global list params.
Admin Endpoints
Section titled “Admin Endpoints”Require the snipshare/moderate ability.
List Reports
Section titled “List Reports”GET /wp-json/snipshare/v1/admin/reports?status=pendingFilter by status: pending, reviewed, dismissed.
Review Report
Section titled “Review Report”PUT /wp-json/snipshare/v1/admin/reports/{id}Body: { "status": "reviewed|dismissed", "trash_paste": false }.
Force Paste Status
Section titled “Force Paste Status”PUT /wp-json/snipshare/v1/admin/pastes/{id}/statusBody: { "status": "active|trashed|expired" }.
Get Embed Data
Section titled “Get Embed Data”GET /wp-json/snipshare/v1/embed/{hash}Public. Returns lightweight paste data for embedding. Private pastes return 404.
Error Responses
Section titled “Error Responses”All errors follow the standard WP REST error format:
{ "code": "rest_forbidden", "message": "You do not have permission to do that.", "data": { "status": 403 }}Common error codes: rest_forbidden (403), rest_not_found (404), rest_invalid_param (400), snipshare_rate_limit_exceeded (429).

