The paste.sr.ht API allows you to browse and create pastes on paste.sr.ht programmatically. This API follows the standard sourcehut API conventions.

#Authentication

Authentication is done via the meta.sr.ht OAuth flow. The following OAuth scopes are available for paste.sr.ht:

  • pastes:read, pastes:write: read & write paste resources
#Resources
#Paste resource
{
  "created": "timestamp",
  "sha": "id of this paste (SHA-1 hash)",
  "user": { short-form user resource },
  "visibility": "access level",
  "files": [
    {
      "filename": "filename" or null,
      "blob_id": "id of this blob (SHA-1 hash)"
    }, ...
  ]
}
#Blob resource
{
  "created": "timestamp",
  "sha": "id of this blob (SHA-1 hash)",
  "contents": "contents of this blob"
}
#Endpoints
#GET /api/pastes

List of paste resources.

OAuth scope: pastes:read

#POST /api/pastes

Create a new paste resource.

OAuth scope: pastes:write

Request body

{
  "visibility": "access level",
  "files": [
    {
      "filename": "filename" or null, (optional)
      "contents": "contents of this file"
    }
  ]
}
  • contents must be a UTF-8 encoded string; binary files are not allowed
  • visibility must be one of "public", "private", or "unlisted"

Response

The new paste resource.

#GET /api/pastes/:sha

Retrieves a paste resource.

OAuth scope: pastes:read

#DELETE /api/pastes/:sha

Deletes a paste resource.

OAuth scope: pastes:write

#GET /api/blobs/:sha

Retrieves a blob resource.

OAuth scope: pastes:read

About this wiki

commit bf6aab980baaf2357fe355e3dfdadec371d6a014
Author: Conrad Hoffmann <ch@bitfehler.net>
Date:   2023-04-19T21:51:23+02:00

packages: update Alpine version
Clone this wiki
https://git.sr.ht/~sircmpwn/sr.ht-docs (read-only)
git@git.sr.ht:~sircmpwn/sr.ht-docs (read/write)