Skip to main content

Developer Documentation

Pythoughts REST API

Build powerful integrations with the Pythoughts publishing platform. Create, publish, and manage blog posts programmatically using our REST API.

Getting Started

Follow these steps to start using the Pythoughts API

1

Create an Account

Sign up for a free account at pythoughts.com/sign-up

2

Generate API Token

Go to Settings → API Tokens and create a new token with the required scopes

Authorization: Bearer pt_your_api_token_here
3

Make Your First Request

Test your token by listing your posts

curl -X GET "https://pythoughts.com/api/v1/posts?page=1&limit=20" \ -H "Authorization: Bearer pt_your_token_here"

Authentication & Scopes

All API requests require a Bearer token with appropriate scopes

posts:read

Read posts and drafts

posts:write

Create, update, and delete posts

posts:publish

Publish and unpublish posts

blogs:read

Read blog information

blogs:write

Create and update blogs

Rate Limits

API requests are rate limited to ensure fair usage

OperationLimitWindow
Read (GET)100 requests1 minute
Write (POST/PUT)60 requests1 minute
Publish10 requests1 hour
Token Creation10 tokens1 hour

Rate Limit Headers

Check X-RateLimit-Remaining and X-RateLimit-Reset headers to monitor your usage

API Endpoints

All endpoints are prefixed with https://pythoughts.com/api/v1

GET
/posts

List all posts with pagination

Required scope: posts:read
GET
/posts/{id}

Get a single post by ID

Required scope: posts:read
POST
/posts

Create a new draft post

Required scope: posts:write
PUT
/posts/{id}

Update an existing post

Required scope: posts:write
DELETE
/posts/{id}

Delete a post permanently

Required scope: posts:write
POST
/posts/{id}/publish

Publish a draft post

Required scope: posts:publish
POST
/posts/{id}/unpublish

Unpublish a published post

Required scope: posts:publish
GET
/blogs

List all blogs for authenticated user

Required scope: blogs:read

HTTP Status Codes

Standard HTTP status codes used by the API

200

OK

Request successful

201

Created

Resource created

400

Bad Request

Invalid request body or parameters

401

Unauthorized

Invalid or missing API token

403

Forbidden

Insufficient permissions or IDOR attempt

404

Not Found

Resource doesn't exist

429

Too Many Requests

Rate limit exceeded

500

Internal Server Error

Server error (contact support)

Client Libraries

Download pre-built client libraries for your favorite language

Python

pythoughts_client.py

Full-featured Python client with type hints and retry logic

Download
JavaScript

pythoughtsClient.js

Modern ES6+ JavaScript client with async/await

Download
TypeScript

pythoughtsClient.ts

Type-safe TypeScript client with comprehensive error handling

Download

Quick Start Examples

Get started quickly with these code snippets

Python

Quick Start
from pythoughts_client import PythoughtsClient

client = PythoughtsClient('pt_your_token_here')

# List posts
posts = client.list_posts(page=1, limit=20)

# Create post
content = {
    'type': 'doc',
    'content': [
        {
            'type': 'paragraph',
            'content': [{'type': 'text', 'text': 'Hello from Python!'}]
        }
    ]
}

post = client.create_post(
    blog_id='your_blog_id',
    title='My Python Post',
    content=content
)

# Publish post
client.publish_post(post['data']['post']['id'])

JavaScript

Quick Start
const PythoughtsClient = require('./pythoughtsClient');

const client = new PythoughtsClient('pt_your_token_here');

// List posts
const posts = await client.listPosts({ page: 1, limit: 20 });

// Create post
const content = {
  type: 'doc',
  content: [
    {
      type: 'paragraph',
      content: [{ type: 'text', text: 'Hello from JavaScript!' }]
    }
  ]
};

const post = await client.createPost({
  blogId: 'your_blog_id',
  title: 'My JavaScript Post',
  content
});

// Publish post
await client.publishPost(post.data.post.id);

TypeScript

Quick Start
import PythoughtsClient from './pythoughtsClient';

const client = new PythoughtsClient('pt_your_token_here');

// List posts
const posts = await client.listPosts({ page: 1, limit: 20 });

// Create post
const content: TiptapContent = {
  type: 'doc',
  content: [
    {
      type: 'paragraph',
      content: [{ type: 'text', text: 'Hello from TypeScript!' }]
    }
  ]
};

const post = await client.createPost({
  blogId: 'your_blog_id',
  title: 'My TypeScript Post',
  content
});

// Publish post
await client.publishPost(post.data.post.id);

Best Practices

Follow these guidelines for secure and efficient API usage

Do

  • ✓ Store tokens in environment variables
  • ✓ Use separate tokens for different environments
  • ✓ Implement exponential backoff for retries
  • ✓ Handle rate limit errors gracefully
  • ✓ Validate responses before processing

Don't

  • ✗ Commit tokens to version control
  • ✗ Log tokens in application logs
  • ✗ Ignore rate limit headers
  • ✗ Make synchronous batch requests
  • ✗ Skip error handling

Need Help?

Join our developer community, explore the interactive Swagger documentation, or reach out to our support team.