NotPeople Bridge

API Reference & Interactive Test Page

Extension Config

Extension ID from Chrome Web Store (pre-filled)

API Reference

How it works

All communication via chrome.runtime.sendMessage(EXTENSION_ID, message, callback). Your site must be listed in the extension's externally_connectable (platform.notpeople.ai or localhost).

// Basic usage pattern chrome.runtime.sendMessage( EXTENSION_ID, { action: "do_post", text: "Hello world" }, (response) => console.log(response) );
Extension must be installed from the Chrome Web Store and page must be on an allowed origin (platform.notpeople.ai or localhost). chrome.runtime will be undefined otherwise.

1. Account

get_account

Returns current Twitter session info. Account is auto-detected from browser cookies — no manual authorization needed.

action: "get_account"
// Response (session active) { "ok": true, "userId": "1234567890", "screenName": "username", "profileImage": "https://pbs.twimg.com/..." } // Response (no session) { "ok": false, "error": "no_session" }

get_tokens

Returns Twitter session cookies (auth_token, ct0, twid) for the current browser session.

action: "get_tokens"
// Response { "ok": true, "tokens": { "auth_token": "...", "ct0": "...", "twid": "u%3D1234567890" }, "userId": "1234567890", "screenName": "username" }

2. Twitter Actions

Common behavior

Every action (post, reply, quote) follows the same flow:

// 1. Checks active Twitter session (cookies) // 2. If images provided — downloads them in background // 3. Opens Twitter tab with appropriate URL // 4. Content script fills text + pastes images // 5. Clicks Post/Reply button // 6. Detects post ID from API intercept // 7. If callbackUrl provided — POSTs result to it
All actions accept an optional callbackUrl — the result will be POSTed there when the tweet is created. No hardcoded callback server.

do_post

Create a new tweet.

action: "do_post"
ParamTypeDescription
textstringrequired Tweet text
userIdstringoptional Expected userId — returns account_mismatch if wrong account is logged in
imageUrlsstring[]optional Image URLs (max 4)
callbackUrlstringoptional URL to POST result to
callbackDataobjectoptional Extra data included in callback

do_reply

Reply to an existing tweet.

action: "do_reply"
ParamTypeDescription
tweetIdstringrequired ID of tweet to reply to
textstringrequired Reply text
userIdstringoptional Expected userId — verifies correct account
imageUrlsstring[]optional Image URLs (max 4)
callbackUrlstringoptional URL to POST result to
callbackDataobjectoptional Extra data included in callback

do_quote

Quote tweet.

action: "do_quote"
ParamTypeDescription
tweetIdstringrequired ID of tweet to quote
textstringrequired Quote comment text
userIdstringoptional Expected userId — verifies correct account
imageUrlsstring[]optional Image URLs (max 4)
callbackUrlstringoptional URL to POST result to
callbackDataobjectoptional Extra data included in callback

3. Cookie Swap

swap_cookies

Swap Twitter session cookies to switch accounts. Closes all Twitter tabs, sets new cookies, verifies session.

action: "swap_cookies"
This closes ALL open Twitter tabs before swapping.

Multi-account post test

Swap to account, post, swap back. Fully automated.

4. Getting Results (wait_result)

wait_result

After calling do_post / do_reply / do_quote, you get a taskId back instantly. Use wait_result to wait for the actual result.

action: "wait_result"
ParamTypeDescription
taskIdstringrequired taskId from action response
timeoutnumberoptional Max wait ms (default: 60000)
// Step 1: Start action const { taskId } = await sendToExtension({ action: "do_post", text: "Hello!", callbackUrl: "http://localhost:8000/callback" }); // Step 2: Wait for result const result = await sendToExtension({ action: "wait_result", taskId: taskId }); // { ok: true, action: "post", postId: "190...", url: "https://x.com/i/status/190..." }

5. Callback

Dynamic callback

Pass callbackUrl with any action request. The extension POSTs the result there when the tweet is created. Each request can use a different URL.

// Callback POST body { "action": "post", "postId": "190...", "url": "https://x.com/i/status/190...", "account": { "userId": "...", "screenName": "..." }, "timestamp": 1710849600000 }

6. Error Reference

ErrorMeaningWhat to do
not_logged_inNo Twitter session in browserLog in to x.com
no_sessionNo active cookiesLog in to x.com
no_cookiesget_tokens found no cookiesLog in to x.com
account_mismatchBrowser logged into different account than expected userIdSwap cookies to correct account first
timeoutwait_result timed outTweet may still post — check callback
session_failedCookie swap could not establish sessionCheck cookie values

7. Full Integration Example

Copy-paste ready

// 1. Set your extension ID const EXT_ID = "joibfanghndmbcmodkoolopdjhloapei"; // 2. Helper function sendToExtension(msg) { return new Promise((resolve, reject) => { if (!chrome.runtime?.sendMessage) { reject(new Error("Extension not available")); return; } chrome.runtime.sendMessage(EXT_ID, msg, (res) => { if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message)); else resolve(res); }); }); } // 3. Execute action and wait for result async function executeAction(action, params) { const start = await sendToExtension({ action, ...params }); if (start.error) return start; const result = await sendToExtension({ action: "wait_result", taskId: start.taskId, timeout: 60000 }); return result; } // 4. Usage // Post with callback const post = await executeAction("do_post", { text: "Hello world!", callbackUrl: "http://localhost:8000/callback" }); // Get account const account = await sendToExtension({ action: "get_account" }); // Get tokens const tokens = await sendToExtension({ action: "get_tokens" });