Minimal Express API to post a tweet (content + optional image) to X (Twitter) and return the result (tweet id + URL).
Interactive Swagger documentation is available at:
http://localhost:3000/api-docs
Open this URL in your browser after starting the server to explore and test all API endpoints with a beautiful UI.
GET /meTest endpoint to verify Twitter API credentials and get authenticated user information.
POST /tweetOptions:
JSON:
{
"content": "Hello from my API 🚀",
"imageUrl": "https://picsum.photos/800/450"
}
multipart/form-data:
content (text)image (file)Response sample:
{
"ok": true,
"tweetId": "1234567890123456789",
"url": "https://x.com/i/web/status/1234567890123456789"
}
pnpm install
cp .env.example .env
# edit your .env with Twitter keys
pnpm start
/i/web/status/{id} which doesn't require the username.Content type
Image
Digest
sha256:cefbaec41…
Size
63.3 MB
Last updated
11 months ago
docker pull nierdna/x-post-api