paste.sr.ht API reference

Table of Contents

This commit

commit 3f0e4882444362cf0f87d0a1aec9d5c376b8e08d
Author: Drew DeVault <sir@cmpwn.com>
Date:   2019-07-11T21:01:54

Correct list of supported characters in tags
Clone this wiki
man@man.sr.ht:root
https://man.sr.ht/root

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:

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"
    }
  ]
}

Response

The new paste resource.

GET /api/pastes/:sha

Retrieves a paste resource.

OAuth scope: pastes:read

GET /api/blobs/:sha

Retrieves a blob resource.

OAuth scope: pastes:read

Webhooks

/api/pastes/...

Webhook for paste events. Includes the standard webhook endpoints

paste:create

Issued when a new paste is created.

OAuth scope: paste:read

Request body

Affected paste resource.