Load Twitter data to Snowflake

Build a Twitter to Snowflake pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Twitter API base URL, auth, endpoints, and incremental loading.

Source
Twitter
Destination
Snowflake
Snowflake is a fully managed cloud data platform that runs on AWS, Azure and Google Cloud. Storage and compute scale independently, so warehouses can be resized or suspended per workload. dlt loads into Snowflake natively, handling schema evolution, incremental loading and staged file uploads.

X (Twitter) API v2 provides programmatic access to posts, users, spaces, lists, and other platform data through REST endpoints. Everything needed to build a working Twitter → Snowflake pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.


Build your Twitter to Snowflake pipeline

Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.

Prompt
Run uvx dlthub-init@latest to build a pipeline from Twitter to Snowflake and run it on dltHub

That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Twitter API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →

Prefer to write it yourself? Every fact the agent uses is below.


Twitter API at a glance

Base URLhttps://api.x.com/2
Example endpointGET 2/tweets
Records found atdata
Authenticationrequests require a Bearer token in the Authorization header — sent in the Authorization header, prefixed Bearer
PaginationCursor-based via pagination_token, page size via max_results. API v2 uses 'max_results' for page size and 'pagination_token' for cursor; API v1.1 used 'count' for page size and 'cursor' for cursor. Always check the specific endpoint documentation.
Incremental fieldnext_token
API referencehttps://docs.x.com/fundamentals/authentication/oauth-2-0/application-only

These values come from the Twitter API reference — the authoritative source if anything here looks out of date.


How do I authenticate with the Twitter API?

Requests require an Authorization header with the Bearer scheme followed by the token string, formatted as 'Authorization: Bearer '.

1. Get your credentials

  1. Navigate to the X Developer Console at console.x.com and sign in with your X account.
  2. Accept the Developer Agreement and provide details about your intended use case.
  3. Create a new App within a Project to serve as a container for your credentials.
  4. Once the app is created, navigate to the Keys and tokens page.
  5. Click 'Generate' or 'Regenerate' to obtain your API Key, API Secret, and Bearer Token. Note: Some credentials (like secrets) are shown only once, so store them immediately in a secure location.
  6. If your use case requires acting on behalf of a specific user, generate an Access Token and Access Secret in the same section.

2. Add them to .dlt/secrets.toml

[sources.twitter_source] bearer_token = "your_bearer_token_here" # If using OAuth 1.0a for user-context: # api_key = "your_api_key" # api_secret = "your_api_secret" # access_token = "your_access_token" # access_token_secret = "your_access_token_secret"

dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.


What Twitter data can I load into Snowflake?

These are the Twitter endpoints dlt can load into Snowflake:

ResourceEndpointMethodData selectorDescription
tweets2/tweetsGETdataRetrieve specific Tweets by ID
users2/usersGETdataRetrieve specific Users by ID
lists2/listsGETdataRetrieve details of specific Lists
recent_search2/tweets/search/recentGETdataRetrieve Tweets from the last 7 days
bookmarks2/users/{id}/bookmarksGETdataRetrieve the bookmarked Tweets of a user

How do I load only new Twitter records?

Twitter exposes next_token on 2/tweets/search/recent, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.

{"name": "recent_search", "endpoint": { "path": "2/tweets/search/recent", "data_selector": "data", "incremental": {"cursor_path": "next_token", "initial_value": "2024-01-01T00:00:00Z"}, }}

On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.


What does the generated Twitter pipeline look like?

A standard dlt REST API pipeline — the same code you would write by hand, loading /2/tweets/search/recent and /2/users/

/tweets from the Twitter API into Snowflake:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def twitter_source(bearer_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.x.com/2", "auth": {"type": "bearer", "token": bearer_token}, }, "resources": [ {"name": "tweets", "endpoint": {"path": "2/tweets", "data_selector": "data"}}, {"name": "recent_search", "endpoint": {"path": "2/tweets/search/recent", "data_selector": "data"}} ], } yield from rest_api_resources(config) def load_twitter_to_snowflake() -> None: pipeline = dlt.pipeline( pipeline_name="twitter_pipeline", destination="snowflake", dataset_name="twitter_data", ) load_info = pipeline.run(twitter_source()) print(load_info) if __name__ == "__main__": load_twitter_to_snowflake()

Run it with uv run python twitter_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.


How do I query Twitter data in Snowflake?

dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("twitter_pipeline").dataset() df = data.recent_search.df() print(df.head())

SQL:

SELECT * FROM twitter_data.recent_search LIMIT 10;

See querying your data with dataset and exploring it in marimo notebooks.


How do I deploy the Twitter to Snowflake pipeline in production?

The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.

  • Deploy & schedule — run the pipeline as a managed job with automatic retries.
  • Monitor — observable job queues, alerting, and load metrics for every run.
  • Transform — promote raw Twitter loads into governed, documented models.
  • Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.

Book a demo →


What other destinations can I load Twitter data to?

dlt loads into any of these — only the destination argument changes:

DestinationExample value
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.


Next steps

Was this page helpful?

Community Hub

Need more dlt context for Twitter to Snowflake?

Request dlt skills, commands, AGENT.md files, and AI-native context.