# Twitter Poster (`pixelated_pulse/twitter-poster`) Actor

Automatically post tweets to Twitter with ease!

- **URL**: https://apify.com/pixelated\_pulse/twitter-poster.md
- **Developed by:** [Pixelated Pulse](https://apify.com/pixelated_pulse) (community)
- **Categories:** Social media, Agents, Integrations
- **Stats:** 46 total users, 2 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Twitter Poster Actor

Automatically post tweets to Twitter with ease! This powerful Actor supports both Twitter API and browser automation methods, giving you flexibility and reliability for your social media automation needs.

### 🚀 Key Features

- **🐦 Dual Posting Methods**: Choose between Twitter API (fast & reliable) or browser automation (no API limits)
- **️ Robust Error Handling**: Comprehensive logging and error reporting
- **📊 Detailed Results**: Complete success/failure tracking in your dataset

### 💡 Perfect For

- **Social Media Managers**: Schedule and automate tweet posting
- **Content Creators**: Distribute content across multiple accounts
- **Marketers**: Execute social media campaigns at scale
- **Developers**: Integrate Twitter posting into your applications
- **Businesses**: Automate customer communications and updates

### 🔧 Two Posting Methods

#### Method 1: Twitter API
- ✅ **Fastest and most reliable**
- ✅ **Official Twitter integration**
- ⚠️ **Requires Twitter API credentials**

#### Method 2: Browser Automation
- ✅ **No API limits or restrictions**
- ✅ **Works with any Twitter account**
- ✅ **Simple authentication token setup**
- ⚠️ **Slower than API method**

### 📝 Input Configuration

#### Required for All Posts
- **Tweet Text**: Your message (max 280 characters)
- **Posting Method**: Choose "api" or "browser"

#### For API Method
You'll need Twitter API credentials:
- **API Key** (`twitterApiKey`): Your Consumer Key
- **API Secret** (`twitterApiSecret`): Your Consumer Secret  
- **Access Token** (`twitterAccessToken`): Your Access Token
- **Access Token Secret** (`twitterAccessSecret`): Your Access Token Secret

[Get your Twitter API credentials here →](https://developer.twitter.com/)

#### For Browser Method
You'll need your Twitter authentication token:
- **Auth Token** (`twitterAuthToken`): Your Twitter auth_token cookie value

**How to get your auth token:**
1. Log into Twitter in your browser
2. Open Developer Tools (F12)
3. Go to Application/Storage → Cookies → x.com
4. Find the "auth_token" cookie and copy its value

### 💻 Usage Examples

#### Post with Twitter API
```json
{
  "tweetText": "Hello world! Posting via API 🚀 #automation",
  "postingMethod": "api",
  "twitterApiKey": "your_api_key_here",
  "twitterApiSecret": "your_api_secret_here",
  "twitterAccessToken": "your_access_token_here",
  "twitterAccessSecret": "your_access_token_secret_here"
}
````

#### Post with Browser Automation

```json
{
  "tweetText": "Hello world! Posting via browser 🤖 #automation",
  "postingMethod": "browser",
  "twitterAuthToken": "your_auth_token_cookie_value_here"
}
```

### 📊 Results & Output

Every run provides detailed results in your Apify dataset:

**Successful Post:**

```json
{
  "success": true,
  "method": "api",
  "tweetText": "Your tweet content",
  "tweetId": "1234567890123456789",
  "tweetUrl": "https://x.com/i/web/status/1234567890123456789",
  "timestamp": "2025-09-10T10:30:00.000Z"
}
```

**Failed Post:**

```json
{
  "success": false,
  "method": "browser",
  "tweetText": "Your tweet content",
  "error": "Detailed error description",
  "timestamp": "2025-09-10T10:30:00.000Z"
}
```

### 🚨 Troubleshooting

#### Common Issues & Solutions

**API Method Issues:**

- `Unauthorized`: Double-check your API credentials
- `Forbidden`: Ensure your Twitter app has write permissions
- `Rate limit exceeded`: Wait before retrying or reduce posting frequency

**Browser Method Issues:**

- `Authentication failed`: Get a fresh auth\_token from your browser
- `Token expired`: Refresh your browser session and get a new token
- `Timeout errors`: Twitter's interface may have changed - contact support

### 🌟 Why Choose This Actor?

- ✅ **Battle-tested**: Used in production for years
- ✅ **Regularly updated**: Maintained and improved continuously
- ✅ **Flexible**: Works with your existing Twitter setup
- ✅ **Reliable**: Built-in error handling and retry logic
- ✅ **Scalable**: From single tweets to high-volume campaigns

***

**Ready to automate your Twitter posting?** Click "Try for free" and start posting tweets in minutes!

*This Actor respects Twitter's Terms of Service and rate limits. Use responsibly for legitimate automation needs.*

# Actor input Schema

## `tweetText` (type: `string`):

The text content of the tweet to post

## `postingMethod` (type: `string`):

Choose how to post the tweet

## `twitterApiKey` (type: `string`):

Your Twitter app's API key. Required when using API posting method.

## `twitterApiSecret` (type: `string`):

Your Twitter app's API secret. Required when using API posting method.

## `twitterAccessToken` (type: `string`):

Your Twitter access token. Required when using API posting method.

## `twitterAccessSecret` (type: `string`):

Your Twitter access token secret. Required when using API posting method.

## `twitterAuthToken` (type: `string`):

Your Twitter auth\_token cookie value. Required when using browser posting method. You can get this from your browser's developer tools when logged into Twitter.

## Actor input object example

```json
{
  "tweetText": "Hello world! This is my first automated tweet.",
  "postingMethod": "browser",
  "twitterAuthToken": "your_auth_token_cookie_value_here"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tweetText": "🚀 Just automated my first tweet using the Twitter Poster Actor! This is amazing for social media automation. #TwitterAutomation #SocialMedia #Apify",
    "postingMethod": "browser",
    "twitterAuthToken": "your_auth_token_cookie_value_here"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pixelated_pulse/twitter-poster").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "tweetText": "🚀 Just automated my first tweet using the Twitter Poster Actor! This is amazing for social media automation. #TwitterAutomation #SocialMedia #Apify",
    "postingMethod": "browser",
    "twitterAuthToken": "your_auth_token_cookie_value_here",
}

# Run the Actor and wait for it to finish
run = client.actor("pixelated_pulse/twitter-poster").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tweetText": "🚀 Just automated my first tweet using the Twitter Poster Actor! This is amazing for social media automation. #TwitterAutomation #SocialMedia #Apify",
  "postingMethod": "browser",
  "twitterAuthToken": "your_auth_token_cookie_value_here"
}' |
apify call pixelated_pulse/twitter-poster --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=pixelated_pulse/twitter-poster",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter Poster",
        "description": "Automatically post tweets to Twitter with ease!",
        "version": "1.0",
        "x-build-id": "7ZySF0YETqrF1LMQx"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/pixelated_pulse~twitter-poster/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-pixelated_pulse-twitter-poster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/pixelated_pulse~twitter-poster/runs": {
            "post": {
                "operationId": "runs-sync-pixelated_pulse-twitter-poster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/pixelated_pulse~twitter-poster/run-sync": {
            "post": {
                "operationId": "run-sync-pixelated_pulse-twitter-poster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "tweetText",
                    "postingMethod"
                ],
                "properties": {
                    "tweetText": {
                        "title": "Tweet Text",
                        "maxLength": 280,
                        "type": "string",
                        "description": "The text content of the tweet to post"
                    },
                    "postingMethod": {
                        "title": "Posting Method",
                        "enum": [
                            "api",
                            "browser"
                        ],
                        "type": "string",
                        "description": "Choose how to post the tweet",
                        "default": "api"
                    },
                    "twitterApiKey": {
                        "title": "Twitter API Key (Consumer Key)",
                        "type": "string",
                        "description": "Your Twitter app's API key. Required when using API posting method."
                    },
                    "twitterApiSecret": {
                        "title": "Twitter API Secret (Consumer Secret)",
                        "type": "string",
                        "description": "Your Twitter app's API secret. Required when using API posting method."
                    },
                    "twitterAccessToken": {
                        "title": "Twitter Access Token",
                        "type": "string",
                        "description": "Your Twitter access token. Required when using API posting method."
                    },
                    "twitterAccessSecret": {
                        "title": "Twitter Access Token Secret",
                        "type": "string",
                        "description": "Your Twitter access token secret. Required when using API posting method."
                    },
                    "twitterAuthToken": {
                        "title": "Twitter Auth Token (Browser Method)",
                        "type": "string",
                        "description": "Your Twitter auth_token cookie value. Required when using browser posting method. You can get this from your browser's developer tools when logged into Twitter."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
