Post Penguin API Documentation
Use the Post Penguin API to programmatically access your blog posts from any backend or CMS.
Authentication
All API requests require an API key. You can create and manage API keys in your dashboard.
Include your API key in one of these ways:
- Header:
X-API-Key: your_api_key - Authorization Header:
Authorization: Bearer your_api_key - Query Parameter:
?api_key=your_api_key
Base URL
https://your-domain.com/api/v1Get Posts
Retrieve blog posts for your sites.
Endpoint
GET /api/v1/postsQuery Parameters
| Parameter | Type | Description |
|---|---|---|
site_id | string | Filter posts by site ID (optional) |
status | string | Filter by status: DRAFT, APPROVED, PUBLISHED (default: PUBLISHED) |
limit | integer | Number of posts to return (default: 10, max: 100) |
offset | integer | Number of posts to skip (default: 0) |
Example Request
curl -X GET "https://your-domain.com/api/v1/posts?limit=10&status=PUBLISHED" \ -H "X-API-Key: your_api_key_here"
Example Response
{
"posts": [
{
"id": "post_id_123",
"title": "Example Blog Post",
"slug": "example-blog-post",
"html": "<p>Post content...</p>",
"meta_title": "SEO Title",
"meta_description": "SEO description",
"featured_image": "https://example.com/image.jpg",
"status": "PUBLISHED",
"published_at": "2024-01-15T10:00:00Z",
"created_at": "2024-01-10T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z",
"site": {
"id": "site_id_456",
"name": "My Blog",
"url": "https://example.com"
}
}
],
"pagination": {
"total": 25,
"limit": 10,
"offset": 0,
"has_more": true
}
}Code Examples
JavaScript/Node.js
const response = await fetch('https://your-domain.com/api/v1/posts?limit=10', {
headers: {
'X-API-Key': 'your_api_key_here'
}
});
const data = await response.json();
console.log(data.posts);PHP
<?php
$apiKey = 'your_api_key_here';
$url = 'https://your-domain.com/api/v1/posts?limit=10';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data['posts']);
?>Python
import requests
api_key = 'your_api_key_here'
url = 'https://your-domain.com/api/v1/posts'
headers = {
'X-API-Key': api_key
}
params = {
'limit': 10,
'status': 'PUBLISHED'
}
response = requests.get(url, headers=headers, params=params)
data = response.json()
print(data['posts'])WordPress
<?php
// In your WordPress theme or plugin
function fetch_postpenguin_posts() {
$api_key = get_option('postpenguin_api_key');
$url = 'https://your-domain.com/api/v1/posts?limit=10';
$response = wp_remote_get($url, [
'headers' => [
'X-API-Key' => $api_key
]
]);
if (is_wp_error($response)) {
return [];
}
$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);
return $data['posts'] ?? [];
}
// Use the function
$posts = fetch_postpenguin_posts();
foreach ($posts as $post) {
// Create WordPress post
wp_insert_post([
'post_title' => $post['title'],
'post_content' => $post['html'],
'post_status' => 'publish',
'post_name' => $post['slug']
]);
}
?>Error Handling
The API uses standard HTTP status codes:
- 200: Success
- 401: Unauthorized - Invalid or missing API key
- 400: Bad Request - Invalid parameters
- 500: Internal Server Error
{
"error": "Invalid or expired API key"
}Rate Limiting
API requests are rate-limited to prevent abuse. If you exceed the limit, you'll receive a 429 status code. Please implement exponential backoff in your client code.