Skip to content

API Overview

The Splinterpic API is organized around REST. Our API has predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes.

All API requests should be made to your deployed Worker URL:

https://your-worker-name.workers.dev

The Splinterpic API uses standard HTTP methods:

MethodUsage
GETRetrieve resources
POSTCreate new resources
PUTUpdate existing resources
DELETERemove resources

All POST and PUT requests must include a Content-Type: application/json header.

All responses are returned as JSON:

{
"id": "img_abc123",
"prompt": "A beautiful sunset",
"created_at": "2024-01-15T10:30:00.000Z"
}

Splinterpic uses conventional HTTP response codes:

CodeMeaning
200Success - Request completed successfully
201Created - Resource was created successfully
400Bad Request - Invalid parameters or request format
403Forbidden - IP not whitelisted or insufficient permissions
404Not Found - Resource doesn’t exist
500Internal Server Error - Something went wrong on our end

When an error occurs, you’ll receive a JSON response with an error field:

{
"error": "Invalid prompt parameter",
"details": {
"field": "prompt",
"message": "Prompt must be at least 3 characters"
}
}

IP Not Whitelisted (403)

HTTP/1.1 403 Forbidden
Forbidden

Invalid Request Body (400)

{
"error": "Invalid request body",
"details": "Expected JSON content-type"
}

Resource Not Found (404)

{
"error": "Image not found",
"details": {
"image_id": "img_invalid"
}
}
EndpointMethodDescription
/api/generatePOSTGenerate a new AI image
/api/imagesGETList all images
/api/images/:idGETGet a specific image
/api/images/:idDELETEDelete an image (soft delete)

Full images documentation →

EndpointMethodDescription
/api/collectionsGETList all collections
/api/collectionsPOSTCreate a new collection
/api/collections/:idGETGet collection details
/api/collections/:id/imagesGETList images in collection
/api/collections/:idDELETEDelete a collection

Full collections documentation →

EndpointMethodDescription
/api/modelsGETList available AI models
/api/models/:idGETGet model details

Full models documentation →

EndpointMethodDescription
/api/analytics/usageGETGet usage statistics
/api/analytics/costsGETGet cost analytics

Full analytics documentation →

Currently, Splinterpic does not implement rate limiting. However, Cloudflare Workers have the following limits:

  • Free Plan: 100,000 requests/day
  • Paid Plan: 10 million requests/day

For high-volume use cases, consider implementing client-side rate limiting or contact us for enterprise options.

Endpoints that return lists support pagination via query parameters:

ParameterTypeDefaultDescription
limitinteger20Number of results per page (max 100)
offsetinteger0Number of results to skip
Terminal window
# Get images 21-40
curl "https://your-worker.workers.dev/api/images?limit=20&offset=20"
{
"images": [...],
"pagination": {
"limit": 20,
"offset": 20,
"total": 150,
"has_more": true
}
}

All timestamps are returned in ISO 8601 format (UTC):

2024-01-15T10:30:00.000Z

To parse in JavaScript:

const date = new Date('2024-01-15T10:30:00.000Z');
console.log(date.toLocaleString());

To parse in Python:

from datetime import datetime
date = datetime.fromisoformat('2024-01-15T10:30:00.000Z'.replace('Z', '+00:00'))
print(date.strftime('%Y-%m-%d %H:%M:%S'))

Currently, all requests use a default user ID (default_user). For multi-tenant deployments, you can extend the authentication system to include user identification.

The Splinterpic API includes CORS headers for all responses:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type

This allows you to make requests from any frontend application.

Image generation requests are not idempotent. Each POST /api/generate request creates a new image, even with identical prompts.

To avoid duplicate generations, implement client-side deduplication or use templates to save generation settings.

The current API version is v1 (implied, not included in URLs). When we release breaking changes, we’ll introduce a versioned API path (e.g., /v2/api/...) and provide migration guides.

Official SDKs are available for:

Community SDKs:

Use the same Worker for development and production. Configure IP whitelisting to include both environments:

[vars]
ALLOWED_IPS = "dev.ip,staging.ip,prod.ip"

The Worker includes sample data (templates and models) inserted via database/schema-init.sql. This data uses user_id = 'system' and should not be deleted.

Need help with the API?