Hub Export API
The Purple Hub offers a REST API for exporting articles with all connected metadata. This API provides the inverse functionality to the Import API, allowing you to retrieve complete post data in the same JSON format used for imports.
API Request
Data | Description | Example |
|---|---|---|
Hub cluster domain | Determines the Hub cluster, data is imported to | demo.purpledshub.com |
Hub identifier | Determines the Hub instance, data is imported to | my-news-portal |
Authorization Token | Securing the call to import data | 1ebe0c0a-1f45-4a57-9823-40fa6afb8e02 |
Post ID | Wordpress post ID to export | 12345 |
The call is performed with the parameters above:
Request GET https://<hub-cluster-domain>/<hub-identifier>/wp-json/purple/v3/export?id=<post-id>
Headers Authorization: Bearer <authorization-token>
Authentication
To retrieve a token you need to call the POST /<hub-identifier>/wp-json/purple/v3/login endpoint. The body needs to include the following parameters as JSON body:
Field | Description |
|---|---|
username | Your username |
password | Your password |
As a response you receive a token that can be used as Authorization token when calling the Export API.
Response Format
The Export API returns the same JSON structure as accepted by the Import API, making it easy to integrate.
JSON Structure
The response closely follows th format of the import API post parameter
{
"externalid": "<external-uuid>",
"post": {
"title": "<title>",
"type": "post",
"date": "<publish-date, format: 2023-01-01T00:00:00+01:00>",
"slug": "<slug>",
"description": "<summary/onlineteaser>",
"content": "<html-content>",
"structured_content": "<structured_content array/>"
},
"assets": [
{
"url": "<asset-url>",
"caption": "<image-caption>",
"acf": {
"field": "value"
}
}
],
"acf": {
"overline": "<overline>",
"isins": [
{
"item": "<isin-1>"
},
{
"item": "<isin-2>"
}
],
"serie": "<series>",
"stadt": "<city>"
},
"featuredImage": [
{
"key": "<key>",
"value": "<value>",
"type": "STRING"
}
],
"taxonomies": {
"category": [
{
"name": "<main-sections>"
}
],
"post_tag": [
{
"name": "<keyword-1>"
},
{
"name": "<keyword-2>"
}
]
},
"authors": [
"<author-1>",
"<author-2>"
]
}Example response
{
"id": 1,
"post": {
"title": "Comprehensive Export Test Article",
"type": "post",
"date": "2023-06-15T14:30:00+00:00",
"slug": "comprehensive-export-test-article",
"description": "",
"content": "Full post content here",
"structured_content": [
{
"id": "123456-1",
"type": "core/heading",
"parentId": "",
"sequence": 0,
"children": [],
"level": 0,
"html": "<h2>Heading here</h2>",
"properties": [
{ "key": "level", "value": 2, "type": "INTEGER" },
{ "key": "purpleId", "value": "123456-1", "type": "STRING" },
{ "key": "content", "value": "Heading here", "type": "STRING" }
]
},
{
"id": "123456-2",
"type": "core/quote",
"parentId": "",
"sequence": 1,
"level": 0,
"html": "<blockquote class=\"wp-block-quote\"><p>Quoted text</p><cite>Author</cite></blockquote>",
"properties": [
{ "key": "content", "value": "", "type": "STRING" },
{ "key": "purpleId", "value": "123456-2", "type": "STRING" },
{ "key": "citation", "value": "Quoted textAuthor", "type": "STRING" }
]
},
{
"id": "123456-3",
"type": "core/image",
"parentId": "",
"sequence": 2,
"children": [],
"level": 0,
"html": "<figure class=\"wp-block-image\">\n <img src=\"https://example.com/image1.png\" alt=\"Test Image\" />\n</figure>",
"properties": [
{ "key": "id", "value": 101, "type": "INTEGER" },
{ "key": "purpleId", "value": "123456-3", "type": "STRING" },
{ "key": "content", "value": "", "type": "STRING" },
{ "key": "url", "value": "https://example.com/image1.png", "type": "STRING" },
{ "key": "mime_type", "value": "image/png", "type": "STRING" },
{ "key": "caption", "value": "", "type": "STRING" },
{ "key": "original_image", "value": "/uploads/image1.png", "type": "STRING" },
{ "key": "meta_img__wp_attached_file", "value": "/uploads/image1.png", "type": "STRING" },
{ "key": "meta_img__wp_attachment_metadata", "value": "{...}", "type": "STRING" }
]
},
{
"id": "123456-4",
"type": "core/group",
"parentId": "",
"sequence": 3,
"children": ["123456-5", "123456-6"],
"level": 0,
"html": "<div class=\"wp-block-group\"><p>Inner para</p><h2>Inner heading</h2></div>",
"properties": [
{ "key": "purpleId", "value": "123456-4", "type": "STRING" },
{ "key": "content", "value": "", "type": "STRING" }
]
},
{
"id": "123456-5",
"type": "core/paragraph",
"parentId": "123456-4",
"sequence": 0,
"children": [],
"level": 1,
"html": "<p>Inner para</p>",
"properties": [
{ "key": "purpleId", "value": "123456-5", "type": "STRING" },
{ "key": "content", "value": "Inner para", "type": "STRING" }
]
},
{
"id": "123456-6",
"type": "core/heading",
"parentId": "123456-4",
"sequence": 1,
"children": [],
"level": 1,
"html": "<h2>Inner heading</h2>",
"properties": [
{ "key": "purpleId", "value": "123456-6", "type": "STRING" },
{ "key": "content", "value": "Inner heading", "type": "STRING" },
{ "key": "level", "value": 2, "type": "INTEGER" }
]
},
{
"id": "123456-7",
"type": "core/post-featured-image",
"parentId": "",
"sequence": 4,
"children": [],
"level": 0,
"html": "",
"properties": [
{ "key": "purpleId", "value": "123456-7", "type": "STRING" },
{ "key": "content", "value": "", "type": "STRING" },
{ "key": "url", "value": "https://example.com/featured.png", "type": "STRING" },
{ "key": "id", "value": 201, "type": "INTEGER" },
{ "key": "mime_type", "value": "image/png", "type": "STRING" },
{ "key": "caption", "value": "", "type": "STRING" },
{ "key": "original_image", "value": "/uploads/featured.png", "type": "STRING" },
{ "key": "meta_img__wp_attached_file", "value": "/uploads/featured.png", "type": "STRING" },
{ "key": "meta_img__wp_attachment_metadata", "value": "{...}", "type": "STRING" }
]
},
{
"id": "123456-8",
"type": "core/media-text",
"parentId": "",
"sequence": 5,
"children": [],
"level": 0,
"html": "<div class=\"wp-block-media-text\"><figure><img src=\"https://example.com/image2.png\" /></figure><div class=\"wp-block-media-text__content\"><p>Some text</p></div></div>",
"properties": [
{ "key": "mediaId", "value": 301, "type": "INTEGER" },
{ "key": "mediaType", "value": "image", "type": "STRING" },
{ "key": "purpleId", "value": "123456-8", "type": "STRING" },
{ "key": "content", "value": "Some text", "type": "STRING" },
{ "key": "id", "value": 301, "type": "INTEGER" },
{ "key": "mime_type", "value": "image/png", "type": "STRING" },
{ "key": "caption", "value": "", "type": "STRING" },
{ "key": "original_image", "value": "/uploads/image2.png", "type": "STRING" },
{ "key": "meta_img__wp_attached_file", "value": "/uploads/image2.png", "type": "STRING" },
{ "key": "meta_img__wp_attachment_metadata", "value": "{...}", "type": "STRING" }
]
},
{
"id": "123456-9",
"type": "core/cover",
"parentId": "",
"sequence": 6,
"children": [],
"level": 0,
"html": "<div class=\"wp-block-cover\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim\"></span>\n<img class=\"wp-block-cover__image-background\" alt=\"\" src=\"https://example.com/image3.png\" data-object-fit=\"cover\" />\n<div class=\"wp-block-cover__inner-container\"><p>Cover content</p></div></div>",
"properties": [
{ "key": "url", "value": "https://example.com/image3.png", "type": "STRING" },
{ "key": "id", "value": 401, "type": "INTEGER" },
{ "key": "purpleId", "value": "123456-9", "type": "STRING" },
{ "key": "content", "value": "Cover content", "type": "STRING" },
{ "key": "mime_type", "value": "image/png", "type": "STRING" },
{ "key": "caption", "value": "", "type": "STRING" },
{ "key": "original_image", "value": "/uploads/image3.png", "type": "STRING" },
{ "key": "meta_img__wp_attached_file", "value": "/uploads/image3.png", "type": "STRING" },
{ "key": "meta_img__wp_attachment_metadata", "value": "{...}", "type": "STRING" }
]
}
]
},
"acf": [
{ "custom_field": "10" },
{ "custom_field2": "13" }
],
"taxonomies": {
"category": [{ "name": "CustomCat" }],
"post_tag": [{ "name": "tag1" }, { "name": "tag2" }]
},
"featuredImage": [
{ "key": "url", "value": "https://example.com/featured.png", "type": "STRING" },
{ "key": "id", "value": 201, "type": "INTEGER" },
{ "key": "mime_type", "value": "image/png", "type": "STRING" },
{ "key": "caption", "value": "", "type": "STRING" },
{ "key": "original_image", "value": "/uploads/featured.png", "type": "STRING" },
{ "key": "meta_img__wp_attached_file", "value": "/uploads/featured.png", "type": "STRING" },
{ "key": "meta_img__wp_attachment_metadata", "value": "{...}", "type": "STRING" }
],
"authors": ["test author 1", "test author 2"],
"assets": [
"https://example.com/image1.png",
"https://example.com/featured.png",
"https://example.com/image2.png",
"https://example.com/image3.png"
]
}
Response Codes and Messages
Successful Response
- 200 - Post data exported successfully
Error Responses
- 400 - Post ID is required
- 401 - No authorization token was provided
- 401 - The authorization token is incorrect
- 404 - Post not found with the given ID
- 500 - An unexpected error occurred while exporting post data
Content Structure
HTML Content The actual content structure reflects the code view of the article in the Purple Hub, including all Gutenberg blocks and custom formatting. Structured Content The content as an array of objects where each block in editor is separate objects in response.
Assets and Media All referenced assets (images, documents, etc.) are included with their full URLs and metadata:
- URL: Direct link to the asset
- Caption: Image caption if set
- ACF Fields: Any custom fields associated with the asset
Taxonomies All taxonomies (categories, tags, custom taxonomies) are exported with their complete metadata, allowing for accurate re-import on destination systems.
Authors Author information is exported as an array of author names as they appear in the source system.
ACF data ACF fields is exported as an array of data as it appears in the source system.
Use Cases
The Export API is designed for:
- Data Migration: Moving content between Hub instances
- Backup Solutions: Creating complete backups of post data
- Third-party Integrations: Exporting data for external systems like print workflows
- Al Processing: Providing structured content data for AI/ML applications
- Content Syndication: Distributing content to partner systems
Security Considerations
- All API calls require valid authentication tokens
- Tokens should be transmitted over HTTPS only
- The same security mechanisms as the Import API are applied
Integration Notes
- The Export API output is mostly compatible with the Import API input format
- No data transformation is needed when moving content between Purple Hub instances
- The externalid from exports can be used for subsequent import operations
- All WordPress post metadata, ACF fields, and custom taxonomies are preserved