Overview
MDShare is a simple API for uploading, sharing, and viewing Markdown documents. Each document gets a unique 8-character ID and a shareable URL. Documents support revision history and embedded images.
API Endpoints
POST /api/upload
Upload a new Markdown document. Returns a unique ID and shareable URL.
Request Formats
1. Multipart Form Data (with images):
curl -X POST \
-F "markdown=@document.md" \
-F "images[]=@image1.png" \
-F "images[]=@image2.jpg" \
https://mdshare.pages.dev/api/upload
2. JSON (markdown only):
curl -X POST \
-H "Content-Type: application/json" \
-d '{"markdown": "# Hello World\n\nThis is my document."}' \
https://mdshare.pages.dev/api/upload
3. JSON (with base64 images):
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"markdown": "# Hello\n\n",
"images": [
{"name": "image.png", "data": "data:image/png;base64,iVBORw0KG..."}
]
}' \
https://mdshare.pages.dev/api/upload
4. Plain Text:
curl -X POST \
-H "Content-Type: text/markdown" \
-d '# Hello World' \
https://mdshare.pages.dev/api/upload
Response:
{
"success": true,
"id": "8f14e45f",
"url": "https://mdshare.pages.dev/view/8f14e45f",
"revision": 1
}
PUT /api/update
Update an existing Markdown document. Creates a new revision.
JSON Request:
curl -X PUT \
-H "Content-Type: application/json" \
-d '{
"id": "8f14e45f",
"markdown": "# Updated Content\n\nThis is the new version."
}' \
https://mdshare.pages.dev/api/update
Multipart Form Data (with new images):
curl -X PUT \
-F "id=8f14e45f" \
-F "markdown=@updated.md" \
-F "images[]=@newimage.png" \
https://mdshare.pages.dev/api/update
Response:
{
"success": true,
"id": "8f14e45f",
"url": "https://mdshare.pages.dev/view/8f14e45f",
"revision": 2
}
GET /api/{id}
Get the raw Markdown content and metadata for a document.
curl https://mdshare.pages.dev/api/8f14e45f
Query Parameters:
| Parameter | Description |
|---|---|
revision |
Get a specific revision (e.g., ?revision=1) |
format |
Set to raw to get plain Markdown text |
Response (JSON):
{
"success": true,
"id": "8f14e45f",
"created": "2025-01-30T12:00:00.000Z",
"updated": "2025-01-30T14:30:00.000Z",
"revision": 2,
"totalRevisions": 2,
"images": ["diagram.png", "screenshot.jpg"],
"content": "# Hello World\n\nThis is my document."
}
GET /view/{id}
View the rendered Markdown document in a web browser.
https://mdshare.pages.dev/view/8f14e45f
Query Parameters:
| Parameter | Description |
|---|---|
revision |
View a specific revision (e.g., ?revision=1) |
The viewer includes:
- Syntax highlighting for code blocks
- Light/dark theme toggle (saved in localStorage)
- Revision selector dropdown
- Rendered images
- GitHub-flavored Markdown support
Images
When you upload images with your Markdown, reference them using relative paths in your Markdown:


Images are served from /img/{id}/{filename} and are automatically
resolved when viewing the document.
Revisions
Every update creates a new revision. You can:
- View any revision using
?revision=N - Use the revision dropdown in the viewer
- Get revision history via the API
LLM Integration Examples
Python (requests)
import requests
# Upload Markdown
response = requests.post(
"https://mdshare.pages.dev/api/upload",
json={"markdown": "# Report\n\nYour analysis results..."}
)
result = response.json()
print(f"View at: {result['url']}")
# Update existing
requests.put(
"https://mdshare.pages.dev/api/update",
json={"id": result['id'], "markdown": "# Updated Report\n\n..."}
)
JavaScript (fetch)
// Upload
const response = await fetch('https://mdshare.pages.dev/api/upload', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ markdown: '# Hello\n\nWorld' })
});
const { id, url } = await response.json();
// Update
await fetch('https://mdshare.pages.dev/api/update', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id, markdown: '# Updated' })
});
cURL One-liner
# Upload from stdin
echo "# Quick Note" | curl -X POST -d @- https://mdshare.pages.dev/api/upload
ID Format
Document IDs are 8-character hexadecimal strings (e.g., 8f14e45f).
They are randomly generated using cryptographic randomness and are case-insensitive.