techapi

The /blog API

Published 2 years ago by sai @ pretzelbox
/blog

The /blog API returns a list of blog posts as a JSON array keyed off blog@your-domain.com. You can use this to design your pug templates or within a user facing html blog built using libraries and frameworks like ReactVueJS, or Svelte. This blog itself is built using HTMX.

Here is the typical JSON structure of a PretzelBox /blog output. Other keys may be sent in the blog JSON but they are to be ignored. 

URL

Getting Started



Note that the origin header field is needed with cURL. AJAX calls made from the browser automatically add the origin header. The API returns the list of blog posts based on the origin field.

Returns
{
  "blog@pretzelbox.cc": [{
    "VersionId": "Wv_zNZkdrUdrW5qa1Ny7QFdJgLW.Ym3s",
    "TagSet": [{
        "Key": "date",
        "Value": "1648541862"
      }, {
        "Key": "size",
        "Value": "17724"
      }, {
        "Key": "eml",
        "Value": "<int
ernal-use>"
      }, {
        "Key": "previewBase64",
        "Value": "
R3JlZXRpbmdzIGZyb20gUHJldHplbEJveA=="
      }, {
        "Key": "spam:virus",
        "Value": "PASS:PASS"
      }, {
        "Key": "senderNameBase64",
        "Value": "c2FpIEAgcHJldHplbGJveDo"
      }, {
        "Key": "subjectBase64",
        "Value": "
SGVsbG8gV29ybGQ="
    }],
    "bucketName": "blog@pretzelbox.cc",
    "s3Bucket": "pb-clients",
    "attachments": [],
    "emlId": "ims0or7"
  }, {
    "VersionId": "2cypt5tDsH.8lN2hXQccXOdGg5orFqsR",
    "TagSet": [{
        "Key": "date",
        "Value": "1648284794"
      }, {
        "Key": "size",
        "Value": "93503"
      }, {
        "Key": "eml",
        "Value": "<internal-user>"
      }, {
        "Key": "previewBase64",
        "Value": "
R3JlZXRpbmdzIGZyb20gUHJldHplbEJveA=="
      }, {
        "Key": "attachmentsSize",
        "Value": "1"
      }, {
        "Key": "spam:virus",
        "Value": "PASS:PASS"
      }, {
        "Key": "senderNameBase64",
        "Value": "c2FpIEAgcHJldHplbGJveDo"
      }, {
        "Key": "subjectBase64",
        "Value": "
SGVsbG8gV29ybGQ="
    }],
    "bucketName": "blog@pretzelbox.cc",
    "s3Bucket": "pb-clients",
    "attachments": [{
      "size": 59597,
      "name": "computer-ged0226db4_640.jpg",
      "location": "https://pretzelbox.cc/blog/hofshrt/computer-ged0226db4_640.jpg"
    }],
    "emlId": "hofshrt"
  }]
}


Details - Top Level Keys

This is the key for the array of blog posts. It is always of the form blog@<your-domain.com>

Each blog post contains the following keys

VersionId
This value can be used in /post API explained here.

TagSet
Array of tags associated with the blog post. These tags are metadata about the blogpost. 

bucketName
Same as the KEY of this array

s3Bucket
Internal use only

attachments
Array of attachments. Pick the location of any image as your featured image.

emlId
The same as the slug referenced in the /post documentation.

Details - TagSet Keys
Below are details of the keys inside the TagSet.

  1. date - unix time in seconds when the post was published
  2. size - size (including attachments) in bytes of the post 
  3. eml - internal use only
  4. previewBase64 base64 encoded post_excerpt
  5. attachmentSize - number of attachments in this email. Not set if the attachment count is 0.
  6. spam:virus - internal user only
  7. senderNameBase64 base64 encoded name of the sended
  8. subjectBase64 - base64 encoded title of the post

Details - Attachment Keys
Below are details of the keys inside the Attachments.
  1. size - size in bytes of the attachment
  2. name - file name
  3. location - publicly available URL of attachment
Attachments