techapi
The /blog API
Published 3 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 React, VueJS, 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
curl https://api.pretzelbox.cc/p/blog -H 'origin:https://pretzelbox.cc'
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": "<internal-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"
}]
}
"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
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.
Usage: curl https://api.pretzelbox.cc/p/post?slug=<emlId> -H 'origin:https://pretzelbox.cc'
Details - TagSet Keys
Below are details of the keys inside the TagSet.
- date - unix time in seconds when the post was published
- size - size (including attachments) in bytes of the post
- eml - internal use only
- previewBase64 - base64 encoded post_excerpt
- attachmentSize - number of attachments in this email. Not set if the attachment count is 0.
- spam:virus - internal user only
- senderNameBase64 - base64 encoded name of the sended
- subjectBase64 - base64 encoded title of the post
Details - Attachment Keys
Below are details of the keys inside the Attachments.
- size - size in bytes of the attachment
- name - file name
- location - publicly available URL of attachment
Attachments