### Install TeaserPaste SDK Source: https://paste.teaserverse.online/docs/python-sdk Installation instructions for the tp-sdk using standard Python package managers like pip or uv. ```bash uv add tp-sdk # or pip install tp-sdk ``` -------------------------------- ### Install TeaserPaste CLI (tpc) Source: https://paste.teaserverse.online/docs/cli Instructions for installing the TeaserPaste CLI (tpc) using automated scripts, Cargo, or Homebrew. The automated installer is recommended for ease of use and updates. ```bash curl --proto '=https' --tlsv1.2 -LsSf https://github.com/TeaserPaste/tpcli/releases/latest/download/tpc-installer.sh | sh ``` ```powershell powershell -ExecutionPolicy Bypass -c "irm https://github.com/TeaserPaste/tpcli/releases/latest/download/tpc-installer.ps1 | iex" ``` ```bash cargo install tpc ``` ```bash brew install TeaserPaste/tools/tpc ``` -------------------------------- ### GET /get Source: https://paste.teaserverse.online/docs/python-sdk Retrieves the content and metadata of a specific snippet. ```APIDOC ## GET /get ### Description Fetch a snippet by its unique identifier. Supports optional password authentication for protected snippets. ### Method GET ### Endpoint /get/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique snippet ID. #### Query Parameters - **pwd** (string) - Optional - Password for protected snippets. ### Response #### Success Response (200) - **Snippet** (Object) - The requested snippet details. ### Response Example { "id": "xyz_123", "content": "Hello World", "visibility": "public" } ``` -------------------------------- ### Get User Info API Request (HTTP GET) Source: https://paste.teaserverse.online/docs/api This example shows a simple HTTP GET request to retrieve public information about the API key owner. No request body is required for this endpoint. ```http GET /getUserInfo HTTP/1.1 Host: api.teaserverse.online Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### List User Snippets API Request (JSON) Source: https://paste.teaserverse.online/docs/api This JSON example illustrates how to request a list of snippets belonging to the current user. Optional parameters like 'limit', 'visibility', and 'includeDeleted' can be included to filter the results. ```json { "limit": 50, "visibility": "public" } ``` -------------------------------- ### Retrieve Snippet Details Source: https://paste.teaserverse.online/docs/api Example JSON response structure returned when successfully fetching a snippet by its ID. ```json { "id": "snippetId123", "title": "Example Snippet", "content": "This is the content.", "language": "javascript", "visibility": "unlisted", "tags": ["example", "demo"], "creatorId": "userId456", "creatorName": "Anonymous", "creatorPhotoURL": "https://url.to/avatar.jpg", "createdAt": "2025-10-08T04:45:00.000Z", "updatedAt": "2025-11-08T15:00:00.000Z", "expiresAt": null, "isVerified": false, "copyCount": 10, "starCount": 5, "passwordBypassed": false } ``` -------------------------------- ### Get User Info Source: https://paste.teaserverse.online/docs/api Retrieves public information about the owner of the provided API key. ```APIDOC ## GET /getUserInfo ### Description Get public information of the API key owner. ### Method GET ### Endpoint /getUserInfo ### Parameters No parameters are required for this endpoint. ### Request Example (No request body or specific parameters needed, just the endpoint call) ### Response #### Success Response (200 OK) Returns public user details. - **userId** (string) - The unique identifier for the user. - **displayName** (string) - The display name of the user. - **photoURL** (string) - The URL to the user's profile picture. #### Response Example ```json { "userId": "userId456", "displayName": "TeaserUser", "photoURL": "https://url.to/user/avatar.jpg" } ``` ``` -------------------------------- ### Get User's Public Snippets Source: https://paste.teaserverse.online/docs/api Fetches a list of public snippets belonging to a specified user. Expired snippets are automatically excluded. ```APIDOC ## POST /getUserPublicSnippets ### Description Get a list of public snippets from a specific user. ### Method POST ### Endpoint /getUserPublicSnippets ### Parameters #### Request Body - **userId** (string) - Required - The ID of the user whose public snippets are to be retrieved. ### Request Example ```json { "userId": "user789" } ``` ### Response #### Success Response (200 OK) Returns an array of public snippet objects for the specified user. Expired snippets are excluded. (Note: The specific structure of snippet objects is not detailed in the provided text.) ``` -------------------------------- ### Get User's Public Snippets API Request (JSON) Source: https://paste.teaserverse.online/docs/api This JSON snippet illustrates how to request a list of public snippets for a specific user. The request body must include the 'userId' of the target user. ```json { "userId": "targetUserId" } ``` -------------------------------- ### Initialize TeaserPaste Client Source: https://paste.teaserverse.online/docs/python-sdk Demonstrates how to authenticate and initialize both synchronous and asynchronous clients using context managers. ```python import tp # Synchronous with tp.TeaserPaste("YOUR_API_KEY") as api: # Your code here # Asynchronous import asyncio async def main(): async with tp.AsyncTeaserPaste("YOUR_API_KEY") as api: # Your async code here asyncio.run(main()) ``` -------------------------------- ### Access CLI Help Source: https://paste.teaserverse.online/docs/cli Displays the built-in help documentation for the Teaserverse CLI tool, providing an overview of available commands and global options. ```bash tpc --help ``` -------------------------------- ### POST /createSnippet Source: https://paste.teaserverse.online/docs/api Create a new snippet in the database using a Private Key. ```APIDOC ## POST /createSnippet ### Description Create a new snippet in the database. Requires a Private Key for authentication. ### Method POST ### Endpoint /createSnippet ### Parameters #### Request Body - **title** (string) - Required - Title of the snippet. - **content** (string) - Required - The text or code content. - **language** (string) - Optional - Programming language (default: plaintext). - **visibility** (string) - Optional - public, unlisted, or private. - **tags** (array) - Optional - Max 10 tags. ### Request Example { "title": "My Snippet", "content": "console.log('Hello');", "language": "javascript", "visibility": "public" } ### Response #### Success Response (201) - **id** (string) - The created snippet ID. ``` -------------------------------- ### Handle SDK Exceptions Source: https://paste.teaserverse.online/docs/python-sdk Demonstrates how to catch specific SDK exceptions like AuthError and NotFoundError for robust error handling. ```python try: api.get("missing_id") except tp.NotFoundError as e: print("Snippet doesn't exist!") except tp.AuthError as e: print("Permission denied!") ``` -------------------------------- ### Create TeaserPaste Snippet Source: https://paste.teaserverse.online/docs/cli Commands for creating new snippets using the TeaserPaste CLI. Supports interactive creation, reading from files, and piping content from standard input. ```bash tpc create -i ``` ```bash tpc create --file "./src/main.rs" --title "My Code" --visibility public ``` ```bash echo "print('Hello World')" | tpc create --title "Script" --language python ``` -------------------------------- ### Configure TeaserPaste CLI (tpc) Source: https://paste.teaserverse.online/docs/cli Commands for configuring the TeaserPaste CLI, including setting API tokens, default languages, and default privacy settings. Authentication is required for private or unlisted snippets. ```bash tpc config set token "your_api_token_here" ``` ```bash tpc config set default_language ``` ```bash tpc config set default_privacy ``` ```bash tpc config get token ``` ```bash tpc config clear token ``` -------------------------------- ### POST /paste Source: https://paste.teaserverse.online/docs/python-sdk Creates a new snippet in the Teaserverse. ```APIDOC ## POST /paste ### Description Creates a new snippet with specified content and metadata. ### Method POST ### Endpoint /paste ### Parameters #### Request Body - **data** (SnippetInput) - Required - Object containing title, content, visibility, and expiry settings. ### Request Example { "title": "Deployment Logs", "content": "All systems go.", "visibility": "unlisted", "expires": "HOUR_1" } ### Response #### Success Response (200) - **Snippet** (Object) - The created snippet object. ### Response Example { "id": "abc_789", "title": "Deployment Logs", "status": "created" } ``` -------------------------------- ### Clone TeaserPaste Snippet Source: https://paste.teaserverse.online/docs/cli Command to download snippet content to a local file using the TeaserPaste CLI. The filename is derived from the snippet title if not provided, and the file extension is automatically added. ```bash tpc clone [filename] [--password ] ``` -------------------------------- ### View TeaserPaste Snippet Source: https://paste.teaserverse.online/docs/cli Command to retrieve and display snippet details and content using the TeaserPaste CLI. Options include viewing raw content, copying to clipboard, displaying the URL, and providing a password for protected snippets. ```bash tpc view [--raw | --copy | --url] [--password ] ``` -------------------------------- ### PUT /edit Source: https://paste.teaserverse.online/docs/python-sdk Updates an existing snippet's content or metadata. ```APIDOC ## PUT /edit ### Description Modify fields of an existing snippet by ID. ### Method PUT ### Endpoint /edit/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the snippet to update. #### Request Body - **title** (string) - Optional - New title. - **content** (string) - Optional - New content. - **visibility** (string) - Optional - New visibility status. ### Response #### Success Response (200) - **Snippet** (Object) - The updated snippet object. ``` -------------------------------- ### Copy (Fork) TeaserPaste Snippet Source: https://paste.teaserverse.online/docs/cli Command to fork an existing snippet into the authenticated user's account using the TeaserPaste CLI. Requires a password for protected snippets. ```bash tpc copy [--password ] ``` -------------------------------- ### Create Snippet Source: https://paste.teaserverse.online/docs/python-sdk Creates a new snippet using the paste method and a SnippetInput model. ```python note = api.paste(tp.SnippetInput( title="Deployment Logs", content="All systems go.", visibility="unlisted", expires=tp.Expiry.HOUR_1 )) ``` -------------------------------- ### POST /restoreSnippet Source: https://paste.teaserverse.online/docs/api Restore a previously deleted snippet to its original state. ```APIDOC ## POST /restoreSnippet ### Description Restore a deleted snippet. System prioritizes restoring to the visibility state stored in oldVisibility. ### Method POST ### Endpoint /restoreSnippet ### Parameters #### Request Body - **snippetId** (string) - Required - The ID of the snippet to restore. ### Response #### Success Response (200) - **message** (string) - Confirmation message. ``` -------------------------------- ### DELETE /kill Source: https://paste.teaserverse.online/docs/python-sdk Performs a soft delete on a snippet. ```APIDOC ## DELETE /kill ### Description Moves a snippet to the trash. ### Method DELETE ### Endpoint /kill/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the snippet to delete. ### Response #### Success Response (200) - **success** (boolean) - Returns true if the operation was successful. ``` -------------------------------- ### List Your Snippets Source: https://paste.teaserverse.online/docs/api Retrieves a list of snippets created by the currently authenticated user. Supports filtering and pagination. ```APIDOC ## POST /listSnippets ### Description Retrieve snippets created by the current user. ### Method POST ### Endpoint /listSnippets ### Parameters #### Request Body - **limit** (number) - Optional - Maximum number of snippets to return (default: 20, max: 100). - **visibility** (string) - Optional - Filter snippets by visibility status (`public`, `unlisted`, `private`, `deleted`). - **includeDeleted** (boolean) - Optional - Whether to include deleted snippets in the results (default: `false`). ### Request Example ```json { "limit": 50, "visibility": "public" } ``` ### Response #### Success Response (200 OK) Returns an array of snippet objects, sorted by `updatedAt`. (Note: The specific structure of snippet objects is not detailed in the provided text.) ``` -------------------------------- ### POST /getSnippet Source: https://paste.teaserverse.online/docs/api Retrieve the content and metadata of a specific snippet by its ID. ```APIDOC ## POST /getSnippet ### Description Retrieve the content and details of a snippet by its ID. A valid API key enables view counting if you are not the owner. ### Method POST ### Endpoint /getSnippet ### Parameters #### Request Body - **snippetId** (string) - Required - The ID of the snippet. - **password** (string) - Optional - Required if the snippet is unlisted and password-protected. ### Request Example { "snippetId": "snippetId123", "password": "optional_password" } ### Response #### Success Response (200) - **id** (string) - Snippet ID - **content** (string) - Snippet text - **visibility** (string) - Current visibility state #### Response Example { "id": "snippetId123", "title": "Example Snippet", "content": "This is the content.", "visibility": "unlisted" } ``` -------------------------------- ### Search Public Snippets Source: https://paste.teaserverse.online/docs/api Searches for public snippets based on a provided term, performing a prefix search. Leverages Redis caching for performance. ```APIDOC ## POST /searchSnippets ### Description Search for `public` snippets using a basic Firestore query (title prefix search). ### Method POST ### Endpoint /searchSnippets ### Parameters #### Request Body - **term** (string) - Required - The search keyword for prefix matching. - **size** (number) - Optional - The number of search results to return (default: 20). - **from** (number) - Optional - This parameter is currently ignored as pagination is unavailable. ### Request Example ```json { "term": "example", "size": 10 } ``` ### Response #### Success Response (200 OK) Returns a list of matching snippet hits, total count, and result size. - **hits** (array) - An array of snippet objects, each containing at least `id` and `title`. - **total** (number) - The total number of snippets matching the search term. - **size** (number) - The number of results returned in this response. - **additional** (object) - Additional information, such as caching status. - **cache** (string) - Indicates if the result was a cache hit or miss. #### Response Example ```json { "hits": [ { "id": "snippetA", "title": "Search Result" } ], "total": 42, "size": 20, "additional": { "cache": "hit" } } ``` ### Note Uses Redis caching for performance. Automatically excludes expired snippets. ``` -------------------------------- ### Update Snippet Metadata Source: https://paste.teaserverse.online/docs/cli Demonstrates how to modify the properties of an existing snippet using the update command. This command supports updating fields such as title and visibility status. ```bash tpc update --title "New Title" --visibility private ``` -------------------------------- ### Authenticate API Requests Source: https://paste.teaserverse.online/docs/api Demonstrates the required HTTP header format for authenticating requests to the TeaserPaste API using a Bearer token. ```http Authorization: Bearer ``` -------------------------------- ### Copy Snippet Source: https://paste.teaserverse.online/docs/api Forks an existing snippet, creating a new private copy under the authenticated user's account. The original snippet's copy count is incremented. ```APIDOC ## POST /copySnippet ### Description Fork an existing snippet into a new **private** snippet under your account. Increments the original's `copyCount`. ### Method POST ### Endpoint /copySnippet ### Parameters #### Request Body - **snippetId** (string) - Required - ID of the source snippet to copy. ### Request Example ```json { "snippetId": "originalSnippetId456" } ``` ### Response #### Success Response (201 Created) Indicates successful copying and provides the ID of the newly created snippet. - **message** (string) - Confirmation message. - **newSnippetId** (string) - The ID of the newly created private snippet. #### Response Example ```json { "message": "Snippet copied successfully.", "newSnippetId": "copiedSnippetId999" } ``` ``` -------------------------------- ### Search Public Snippets API Request (JSON) Source: https://paste.teaserverse.online/docs/api This JSON snippet demonstrates a request to search for public snippets. It requires a 'term' for the search query and optionally accepts 'size' for the number of results. The 'from' parameter is currently ignored. ```json { "term": "exampleSearchTerm", "size": 10 } ``` -------------------------------- ### PATCH /updateSnippet Source: https://paste.teaserverse.online/docs/api Update an existing snippet's properties. Only accessible by the snippet owner. ```APIDOC ## PATCH /updateSnippet ### Description Update an existing snippet. Only the owner can perform this action. ### Method PATCH ### Endpoint /updateSnippet ### Parameters #### Request Body - **snippetId** (string) - Required - The ID of the snippet to update. - **updates** (object) - Required - Fields to update (title, content, language, visibility, etc.). ### Request Example { "snippetId": "snippetId123", "updates": { "title": "Updated Title" } } ``` -------------------------------- ### Copy Snippet API Request (JSON) Source: https://paste.teaserverse.online/docs/api This JSON snippet shows the structure for requesting to copy an existing snippet. It requires the ID of the snippet to be copied. Upon successful execution, the API returns a confirmation message and the ID of the newly created snippet. ```json { "snippetId": "sourceSnippetId" } ``` -------------------------------- ### Star/Unstar Snippet Source: https://paste.teaserverse.online/docs/api Allows users to star (like) or unstar a snippet. This action updates the snippet's star count and notifies the owner. ```APIDOC ## POST /starSnippet ### Description Star (like) or unstar a snippet. Updates `starCount` and notifies the owner. ### Method POST ### Endpoint /starSnippet ### Parameters #### Request Body - **snippetId** (string) - Required - The ID of the snippet to star or unstar. - **star** (boolean) - Required - `true` to star the snippet, `false` to unstar it. ### Request Example ```json { "snippetId": "snippet123", "star": true } ``` ### Response #### Success Response (200 OK) Returns the status of the operation and the updated star count. - **status** (string) - The result of the operation (e.g., `starred`, `unstarred`, `already_starred`, `already_unstarred`). - **starCount** (number) - The updated number of stars for the snippet. #### Response Example ```json { "status": "starred", "starCount": 6 } ``` ``` -------------------------------- ### DELETE /deleteSnippet Source: https://paste.teaserverse.online/docs/api Perform a soft delete on a snippet by changing its visibility. ```APIDOC ## DELETE /deleteSnippet ### Description Mark a snippet as deleted by setting visibility to 'deleted'. Only the owner can perform this. ### Method DELETE ### Endpoint /deleteSnippet ### Parameters #### Request Body - **snippetId** (string) - Required - The ID of the snippet to delete. ### Response #### Success Response (200) - **message** (string) - Confirmation message. ``` -------------------------------- ### Star/Unstar Snippet API Request (JSON) Source: https://paste.teaserverse.online/docs/api This snippet demonstrates how to construct a JSON request to star or unstar a snippet. It requires the snippetId and a boolean 'star' field to indicate the desired action. The API responds with the status of the operation and the updated star count. ```json { "snippetId": "yourSnippetId", "star": true } ``` -------------------------------- ### Star/Unstar TeaserPaste Snippet Source: https://paste.teaserverse.online/docs/cli Command to toggle the star status of a snippet using the TeaserPaste CLI. The `--unstar` option can be used to remove a star. ```bash tpc star [--unstar] ``` -------------------------------- ### Update Snippet Source: https://paste.teaserverse.online/docs/python-sdk Modifies an existing snippet by passing updated fields as keyword arguments to the edit method. ```python api.edit("xyz_123", title="Updated Title", visibility="private") ``` -------------------------------- ### Restore Snippet Response Source: https://paste.teaserverse.online/docs/api The confirmation message returned after successfully restoring a previously deleted snippet. ```json { "message": "Snippet 'snippetId123' has been restored to 'private'." } ``` -------------------------------- ### Delete Snippet Response Source: https://paste.teaserverse.online/docs/api The confirmation message returned after successfully performing a soft delete on a snippet. ```json { "message": "Snippet 'snippetId123' has been moved to trash." } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.