Twitter/X

The Twitter/X source collects posts, replies, and public account content from Twitter/X as part of a Data Stream.

📘

Datastreamer selects from available providers automatically based on your Job configuration. You do not need to manage provider accounts or credentials to use this source.

API data_source: twitter_auto


Configuring a Job

Every X/Twitter Job sets query.platform to twitter and passes a search expression in query.query, using X/Twitter search operators (see X/Twitter Query Syntax below). This source has no query_type.

Job options

FieldDescription
query.prioritizationfreshness favors newer documents; coverage favors collecting a greater volume. See Freshness or Coverage.
job_typeonetime runs once over a date range; periodic runs on a schedule.
query_from, query_toOne-time Jobs only. Start and end of the date range, in ISO 8601 format. Both are required.
max_documentsOptional. Maximum documents to return. This is a soft limit: because pipelines are asynchronous, a few more documents may be returned.
query.per_day_limitOptional. Maximum documents to return per day, for date ranges longer than 24 hours.
query.include[].max_documentsOptional. Collects comments with each post, up to this many per post (a soft limit). Example: "include": [{ "max_documents": 10 }].
label, tagsOptional. A label for grouping Jobs, and tags for filtering.

Example Job request

curl --request POST \
  --url 'https://api.platform.datastreamer.io/api/pipelines/{PIPELINE_ID}/components/{COMPONENT_ID}/jobs?ready=true' \
  --header 'apikey: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "job_name": "twitter-example",
  "component_name": "twitter-auto",
  "query": {
    "platform": "twitter",
    "query": "(electric OR hybrid) vehicle lang:en",
    "prioritization": "coverage",
    "include": [
      {
        "max_documents": 10
      }
    ],
    "per_day_limit": 500
  },
  "data_source": "twitter_auto",
  "job_type": "onetime",
  "query_from": "2026-10-01T00:00:00Z",
  "query_to": "2026-10-02T00:00:00Z",
  "max_documents": 1000
}'

Refer to the Job creation documentation for full configuration details: Creating Jobs

API Reference: Create a Job

⚠️

Do not include dates in your query string.

The Job system handles date ranges and historical searches. Including dates inside the query may cause errors or limit provider selection.


Twitter/X Query Syntax

Queries for the Twitter/X source use Twitter/X advanced search formatting. The table below covers the most common operators. For how query types are interpreted across sources, see Query Handling.

OperatorExampleDescription
Phrase"dog house"Exact phrase match
NOT-mouseExclude this term
Fromfrom:catPosts from this handle (no @ symbol)
Toto:dogPosts directed at this handle (no @ symbol)
Hashtag(#dogsrule)Hashtags in parentheses, always with # symbol
Languagelang:enISO 2-letter language code
Replies onlyfilter:repliesFilter to replies only (default includes both posts and replies)
Min repliesmin_replies:100Minimum reply count
Min likesmin_faves:100Minimum like count
Min retweetsmin_retweets:100Minimum retweet/repost count
Has linkfilter:linksOnly posts containing links

Twitter/X treats spaces as AND and uses negation with a minus sign rather than NOT. Examples:

IntentQueryBoolean equivalent
Either termcat OR dogcat OR dog
Both termscat dogcat AND dog
Exclude a term(cat OR dog) -mouse(cat OR dog) NOT mouse
Combined(cat OR dog) ferret(cat OR dog) AND ferret
Complex(cat OR dog) mouse from:parrot(cat OR dog) AND mouse AND from:parrot

A query is limited to 400 characters.

For a full reference, see X Advanced Search.


What is Collected

Each document returned from the Twitter/X source represents a post or reply. Fields are mapped to the Datastreamer unified schema and include content text, author metadata, engagement metrics (likes, retweets, replies, quotes), and post date.

Platform-specific fields are available under the twitter schema namespace. See the Schema Reference for field details.


Troubleshooting

Job fails or returns no data

  • Check that the query syntax is valid
  • Verify the date range contains data
  • Confirm filters are not too restrictive
  • Review Job logs for specific errors

Unexpectedly high document counts

  • Add engagement filters (e.g. min_faves, min_retweets) to reduce volume
  • Set a document limit on the Job
  • Review the DVU pricing page

Provider switch noted in Job logs

  • This is expected behavior. If a provider is unavailable, the Job is routed to an alternative automatically. No action is required.

Related


Did this page help you?