Skip to main content

Code Examples

This page provides complete workflow examples for common Soku API tasks. Each example is shown in curl, JavaScript (Node.js), and Python to help you get started quickly.

Setup

Environment Variable

All examples assume your API key is stored in an environment variable:

JavaScript Base Configuration

The JavaScript examples use the built-in fetch API available in Node.js 18+. Here is a reusable helper function used throughout this page:

Python Base Configuration

The Python examples use the requests library. Install it with pip install requests.

Publish a Text Post

Post a text update to multiple platforms at once.

curl

JavaScript

Python


Upload Media and Publish a Video Post

Upload a video from a remote URL, then publish it to multiple platforms.

curl

JavaScript

Python


Publish an Image Post with Multiple Images

curl

JavaScript

Python


Generate an OG Image and Publish

Render a template image and publish it as an image post.

curl

JavaScript

Python


Transcribe a Video

Submit a video for AI transcription.

curl

JavaScript

Python


Schedule a Post for Later

Schedule a post to be published at a specific future time.

curl

JavaScript

Python


Error Handling with Retry Logic

A production-ready request function with automatic retry for transient errors.

JavaScript

Python


Batch Publishing Workflow

Publish multiple posts sequentially with rate limit awareness.

JavaScript

Python


API Key Rotation

Programmatically rotate an API key. This example uses Firebase ID token authentication for the key management endpoints.

curl

JavaScript

Python


Next Steps