Knowledge BaseUltimate Markdown › REST API

Reading Documents with the REST API

The plugin allows you to read internal Markdown documents stored in the Documents menu using the REST API.

This is done by sending requests to a dedicated endpoint provided by the plugin.

Why Use This Endpoint

Reading documents via the REST API is useful when you need to:

  • Integrate with external applications or services
  • Build custom publishing workflows
  • Sync content with external systems
  • Access Markdown content programmatically

Endpoint Information

Action

Retrieve one or more Markdown documents stored in the plugin.

Base route

/wp-json/ultimate-markdown-pro/v1/documents

Method

GET

URL Parameters

  • document_id – (optional) The ID of the document to retrieve. Leave empty to retrieve all documents.
  • rest_api_key – (required only if using API Key authentication)

Reading Documents

To retrieve documents:

  1. Configure authentication in
    REST API → Authentication (Read). (see the authentication documentation for details)
  2. Send a GET request to:
/wp-json/ultimate-markdown-pro/v1/documents

JavaScript Example (Read All Documents)

async function getDocuments() {
const endpoint = 'https://example.com/wp-json/ultimate-markdown-pro/v1/documents';

const params = new URLSearchParams({
rest_api_key: 'YOUR_API_KEY' // remove if not required
});

try {
const response = await fetch(`${endpoint}?${params.toString()}`, {
method: 'GET'
});

const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error fetching documents:', error);
}
}getDocuments();

JavaScript Example (Read a Specific Document)

async function getSingleDocument(documentId) {
const endpoint = 'https://example.com/wp-json/ultimate-markdown-pro/v1/documents';

const params = new URLSearchParams({
document_id: documentId,
rest_api_key: 'YOUR_API_KEY' // remove if not required
});

try {
const response = await fetch(`${endpoint}?${params.toString()}`, {
method: 'GET'
});

const data = await response.json();
console.log(`Document ${documentId}:`, data);
} catch (error) {
console.error('Error fetching document:', error);
}
}

getSingleDocument(1);

Example Response

A successful request returns a JSON response similar to:

[
{
"document_id": 1,
"title": "Sample Document",
"content": "## Heading\r\nMarkdown content here...",
"category_id": "2"
}
]

Notes

  • If document_id is omitted, all documents are returned
  • Authentication depends on your configuration (Cookies, API Key, or None)
  • For production environments, avoid exposing API keys in client-side code

cURL Examples

Read All Documents

Retrieve all available documents:

curl -X GET "https://example.com/wp-json/ultimate-markdown-pro/v1/documents?rest_api_key=YOUR_API_KEY"

Read a Specific Document

Retrieve a single document by specifying the document_id:

curl -X GET "https://example.com/wp-json/ultimate-markdown-pro/v1/documents?document_id=1&rest_api_key=YOUR_API_KEY"

Without API Key

If authentication is not required, omit the rest_api_key parameter:

curl -X GET "https://example.com/wp-json/ultimate-markdown-pro/v1/documents"