Code Examples
Ready-to-use examples in popular languages.
cURL
List accounts
curl https://crelio.app/api/v1/accounts \
-H "Authorization: Bearer YOUR_API_KEY"Create a post
curl -X POST https://crelio.app/api/v1/social-posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountIds": ["acc_123"],
"content": "Hello from the API!",
"autoSchedule": true
}'Create a post with media and custom interval
curl -X POST https://crelio.app/api/v1/social-posts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountIds": ["acc_123"],
"content": "Daily update!",
"autoSchedule": true,
"autoScheduleInterval": 24,
"mediaUrl": "https://example.com/video.mp4"
}'Get post status
curl https://crelio.app/api/v1/social-posts/POST_ID \
-H "Authorization: Bearer YOUR_API_KEY"List posts with filter
curl "https://crelio.app/api/v1/social-posts?status=SCHEDULED&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"JavaScript / Node.js
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://crelio.app/api/v1";
const headers = {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
};
// List accounts
async function listAccounts() {
const res = await fetch(`${BASE_URL}/accounts`, { headers });
return res.json();
}
// Create a post
async function createPost(accountIds, content, options = {}) {
const res = await fetch(`${BASE_URL}/social-posts`, {
method: "POST",
headers,
body: JSON.stringify({
accountIds,
content,
autoSchedule: true,
idempotencyKey: `post-${Date.now()}`,
...options,
}),
});
return res.json();
}
// Get post status
async function getPost(postId) {
const res = await fetch(`${BASE_URL}/social-posts/${postId}`, { headers });
return res.json();
}
// Batch create
async function batchCreate(posts) {
const res = await fetch(`${BASE_URL}/social-posts/batch`, {
method: "POST",
headers,
body: JSON.stringify({ posts }),
});
return res.json();
}
// Usage
const accounts = await listAccounts();
const post = await createPost([accounts.accounts[0].id], "Hello from Node.js!", {
mediaUrl: "https://example.com/image.jpg",
});
console.log(`Post ${post.id} status: ${post.status}`);Python
import requests
from datetime import datetime, timedelta
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://crelio.app/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
def list_accounts():
"""Get all connected social accounts."""
response = requests.get(f"{BASE_URL}/accounts", headers=headers)
response.raise_for_status()
return response.json()
def create_post(account_ids, content, **kwargs):
"""Create a new social post."""
data = {
"accountIds": account_ids,
"content": content,
"autoSchedule": True,
**kwargs,
}
response = requests.post(
f"{BASE_URL}/social-posts", headers=headers, json=data
)
response.raise_for_status()
return response.json()
def get_post(post_id):
"""Get a post by ID."""
response = requests.get(
f"{BASE_URL}/social-posts/{post_id}", headers=headers
)
response.raise_for_status()
return response.json()
def batch_create(posts):
"""Create multiple posts at once."""
response = requests.post(
f"{BASE_URL}/social-posts/batch",
headers=headers,
json={"posts": posts},
)
response.raise_for_status()
return response.json()
# Usage
accounts = list_accounts()
account_id = accounts["accounts"][0]["id"]
post = create_post(
[account_id],
"Hello from Python!",
mediaUrl="https://example.com/image.jpg",
)
print(f"Post {post['id']} status: {post['status']}")