Examples and use cases
The Sitepaste API opens up endless possibilities for automating your content publishing workflow. Here are some creative ways to integrate the API into your daily tools and processes.
iPhone shortcuts
Publish directly from your iPhone using Apple Shortcuts. Share a note from Apple Notes, Drafts, or any app and have it automatically posted to your site.
Quick note to blog post
This shortcut takes text from the share sheet and publishes it as a blog post:
Setup:
- Open Shortcuts app on iPhone
- Create new shortcut
- Add “Get text from Share Sheet”
- Add “Get contents of URL” action
- Configure as shown below
Shortcut configuration:
- URL:
https://sitepaste.com/api/v1/public/pages - Method:
POST - Headers:
Authorization: Bearer sp_your_token_hereContent-Type: application/json
- Body type JSON:
title: “Your title”content: “Your content”
Pro tip: Use “Ask for Input” to set the title dynamically, or parse it from the first line of your note.
Apple notes to documentation
Parse structured notes with headers and publish as documentation:
# Get note content from share sheet
# Split by first line (title) and rest (content)
# Format as API request
{
"title": "[First Line]",
"content": "[Rest of Note]",
"contentType": "docs",
"tags": ["from-iphone"]
}
Add a second action to trigger a build:
URL: https://sitepaste.com/api/v1/public/builds
Method: POST
Headers:
Authorization: Bearer sp_your_token_here
Now you can write in Notes and publish with one tap from the share sheet.
VSCode extension
Create a VSCode extension to publish markdown files directly from your editor.
extension.ts:
import * as vscode from 'vscode';
export async function publishToSitepaste() {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
const { document } = editor;
const content = document.getText();
const fileName = document.fileName.split('/').pop()?.replace('.md', '') ?? 'untitled';
const config = vscode.workspace.getConfiguration('sitepaste');
const token = config.get<string>('apiToken');
const response = await fetch('https://sitepaste.com/api/v1/public/pages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: fileName,
content,
contentType: 'docs'
})
});
if (response.ok) {
vscode.window.showInformationMessage('Published to Sitepaste!');
} else {
const { error } = await response.json();
vscode.window.showErrorMessage(`Failed to publish: ${error}`);
}
}
Bind it to a keyboard shortcut and publish with Cmd+Shift+P.
Obsidian plugin
Sync your Obsidian vault to your Sitepaste site automatically.
Key features:
- Watch for file changes in specific folders
- Parse frontmatter for metadata
- Upload modified files
- Handle images and attachments
- Trigger builds on demand
Sample code:
async publishNote(file) {
const content = await this.app.vault.read(file);
const frontmatter = this.parseFrontmatter(content);
await fetch('https://sitepaste.com/api/v1/public/pages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.settings.apiToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: frontmatter.title || file.basename,
content: content,
slug: frontmatter.slug,
tags: frontmatter.tags,
draft: frontmatter.draft || false
})
});
}
CLI tool
Build a command-line tool for batch operations and scripting.
sitepaste-cli:
#!/bin/bash
# Publish all markdown files in a directory
SITEPASTE_TOKEN="sp_your_token_here"
API_BASE="https://sitepaste.com/api/v1"
for file in *.md; do
title=$(head -n 1 "$file" | sed 's/^# //')
content=$(cat "$file")
echo "Publishing: $title"
curl -s -X POST "$API_BASE/public/pages" \
-H "Authorization: Bearer $SITEPASTE_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--arg title "$title" \
--arg content "$content" \
'{title: $title, content: $content, contentType: "docs"}')"
sleep 1
done
echo "Triggering build..."
curl -s -X POST "$API_BASE/public/builds" \
-H "Authorization: Bearer $SITEPASTE_TOKEN"
echo "Done!"
Usage:
chmod +x sitepaste-cli
./sitepaste-cli
GitHub actions
Automatically publish documentation when code is merged.
.github/workflows/publish-docs.yml:
name: Publish Documentation
on:
push:
branches: [main]
paths: ['docs/**']
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Publish to Sitepaste
env:
SITEPASTE_TOKEN: ${{ secrets.SITEPASTE_TOKEN }}
run: |
for file in docs/**/*.md; do
filename=$(basename "$file" .md)
curl -X POST https://sitepaste.com/api/v1/public/pages \
-H "Authorization: Bearer $SITEPASTE_TOKEN" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"title": "$filename",
"content": $(jq -Rs . < "$file"),
"contentType": "docs"
}
EOF
done
- name: Trigger Build
env:
SITEPASTE_TOKEN: ${{ secrets.SITEPASTE_TOKEN }}
run: |
curl -X POST https://sitepaste.com/api/v1/public/builds \
-H "Authorization: Bearer $SITEPASTE_TOKEN"
Your docs are now always in sync with your codebase.
Raycast quicklink
Publish from clipboard with a keyboard shortcut on macOS.
Create a script and add it as a Raycast quicklink:
#!/bin/bash
curl -s -X POST "https://sitepaste.com/api/v1/public/pages" \
-H "Authorization: Bearer $SITEPASTE_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg title "$1" --arg content "$(pbpaste)" '{title: $title, content: $content, contentType: "blog"}')"
Pass the title as an argument and the script will use your clipboard as the content.
Slack bot integration
Let your team publish updates directly from Slack.
Slack Bot Command:
app.command('/publish', async ({ command, ack, respond }) => {
await ack();
const [title, ...contentParts] = command.text.split('\n');
const content = contentParts.join('\n');
const response = await fetch('https://sitepaste.com/api/v1/public/pages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SITEPASTE_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
title,
content,
contentType: 'blog',
tags: ['from-slack']
})
});
if (response.ok) {
await respond(`Published: ${title}`);
} else {
const { error } = await response.json();
await respond(`Failed to publish: ${error}`);
}
});
Usage in Slack:
/publish Weekly Update
# This Week's Highlights
- Shipped new API
- 100+ users signed up
- Fixed critical bugs
File watcher & auto-publish
Monitor a folder and auto-publish when files change.
Node.js with Chokidar:
import chokidar from 'chokidar';
import { readFile } from 'fs/promises';
const watcher = chokidar.watch('./content/**/*.md', {
persistent: true
});
watcher.on('change', async (path) => {
console.log(`File changed: ${path}`);
const content = await readFile(path, 'utf8');
const title = path.split('/').pop()?.replace('.md', '') ?? 'untitled';
await fetch('https://sitepaste.com/api/v1/public/pages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SITEPASTE_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
title,
content,
contentType: 'docs'
})
});
console.log(`Published: ${title}`);
});
console.log('Watching for changes...');
Perfect for local-first writing workflows.
Notion database sync
Sync a Notion database to your Sitepaste site.
Key steps:
- Use Notion API to query database
- Convert Notion blocks to Markdown
- Publish to Sitepaste
- Run on schedule with cron or GitHub Actions
Sample:
import { Client } from '@notionhq/client';
const notion = new Client({ auth: process.env.NOTION_TOKEN });
async function syncNotionToSitepaste() {
const response = await notion.databases.query({
database_id: process.env.NOTION_DATABASE_ID!,
filter: { property: 'Status', select: { equals: 'Published' } }
});
for (const page of response.results) {
const title = page.properties.Name.title[0].plain_text;
const blocks = await notion.blocks.children.list({ block_id: page.id });
const content = convertBlocksToMarkdown(blocks.results);
await publishToSitepaste(title, content);
}
}
What will you build?
These are just starting points. The API enables you to:
- Write in your favorite tools
- Automate repetitive tasks
- Integrate with existing workflows
- Build custom publishing pipelines
- Create team collaboration features
Got a creative use case? Share it with the community or contact support - we’d love to feature it!
Getting started
Ready to build your integration?
- Create an API token
- Review the Pages API and Builds API
- Start building!
Need help? Check the Introduction for API basics.