Twitter (X) Notion Integration: Send Tweets to a Notion Database with Python

- Two APIs, one loop: search X with
/twitter/tweet/advanced_search, thenPOST https://api.notion.com/v1/pageson Notion withparent.data_source_idand aNotion-Versionheader. - Dedupe by tweet ID: store the ID in a
Tweet IDtext property, read the recent IDs once per run withPOST https://api.notion.com/v1/data_sources/{id}/query, and skip matches. In our re-poll, 40 of 40 returned posts were already on the board. - Measured volume: a three-phrase Notion keyword search produced 630 posts in 7 days, 76 to 117 a day, mean 90, from 435 distinct authors.
- Split long text: 56 of 630 posts (8.9%) exceeded Notion's 2,000-character rich_text limit; the longest (11,084 characters) needs 6 chunks of 1,900.
- Pace Notion, not X: at an average of 3 requests per second, a day's 90 pages take about 30 seconds to write; honor
429and theRetry-Afterheader. - Cost: about $0.014 a day and $0.41 a month for the X data at $0.15 per 1,000 tweets, vs $13.50 a month for the same posts on the official X API at $0.005 per post read.
This page is about sending any public X data (a keyword search, a hashtag, a set of accounts) into a Notion database as one page per post. It is not about your private bookmarks: our X bookmarks AI guide covers exporting the posts you saved with X's Bookmark button and handing them to Notion, Obsidian or an AI assistant. Here, the source is public search results, the destination is a Notion database you share with a connection, and the hard parts are deduplication, property mapping and Notion's request limits.
Search for a Twitter Notion integration and you mostly find automation templates (Zapier, Make, IFTTT, Pabbly Connect) and browser extensions that clip one post at a time. Templates work for a single account's new posts, but they hide the parts that decide whether a research board stays clean: what happens when a post is seen twice, where a 3,000-character long post goes, and what a week of a busy keyword actually adds up to. We measured that week on real X data, wrote the script against the current Notion API reference, and kept every number on this page traceable to the study files.
One honest boundary up front: we did not write to a Notion workspace for this page. The X half of the script ran against our API for the study, and the Notion half follows developers.notion.com as fetched this year (endpoints, headers, property shapes, limits). Where the Notion docs leave something unstated, the code takes the conservative choice and the text says so.
90
How the integration works: four steps, two APIs
Every Twitter-to-Notion pipeline, whether a no-code template or a script, does the same four things. Seeing them separately makes it easy to choose where each one lives.
1. Read posts from X. For a research board, the source is usually a search: a product name, a set of phrases, a hashtag or a few accounts joined with from:a OR from:b. On TwitterAPI.io that is GET /twitter/tweet/advanced_search with query and queryType=Latest. Each page returns up to 20 posts plus has_next_page and next_cursor, and the since_time: and until_time: operators (Unix seconds) inside the query pin the window so each run reads only the period it owns. No X account is needed for reads.
2. Dedupe. Before creating anything, the script reads which Tweet IDs the board already holds for that window, using POST https://api.notion.com/v1/data_sources/{data_source_id}/query with a date filter. Anything already present is skipped. This is what lets you re-run a day, widen a window or recover from a crash without duplicate rows.
3. Map fields to properties. The X post's text, id, url, author.userName, createdAt, lang, likeCount, viewCount, entities.hashtags and extendedEntities.media become Notion property values of the matching types (title, rich_text, url, date, select, number, multi_select, checkbox).
4. Create one page per post. POST https://api.notion.com/v1/pages with parent: {"data_source_id": ...}, the properties object and, for the full text, children paragraph blocks. The request carries Authorization: Bearer <token>, Notion-Version and Content-Type: application/json.
Set up the Notion side: a database, a connection, a data source ID
Create the database. In Notion, add a full-page database and give it these properties, with these exact names and types: Name (title, every database has exactly one), Tweet ID (text), URL (URL), Author (text), Posted (date), Language (select), Likes (number), Views (number), Has media (checkbox) and Hashtags (multi-select). Property names in the API request must match the schema, so rename either side rather than guessing.
Get a token. Notion's developer docs now describe two kinds of credentials. A personal access token, created under Personal access tokens in the developer portal (notion.so/developers/tokens), starts with ntn_ and acts as the user who created it, with that user's permissions. An internal connection token works too, but an internal connection sees nothing by default: per the authorization guide, the page must be manually shared with the connection through the three-dot menu and Add connections, or every request returns an error. Either way the token travels as Authorization: Bearer <token>, and it belongs in an environment variable, never in browser code or a public repository.
Find the data source ID. Since API version 2025-09-03, Notion splits a database (the container) from its data sources (the tables inside it), and pages are created under a data source. Copy the database ID from the database URL, call GET https://api.notion.com/v1/databases/{database_id}, and read data_sources[0].id from the response. A database you created normally has exactly one data source; if you added more, pick the one by name.
Pin the API version. The Notion-Version header is required. The create-page reference lists the accepted values and marks the newest one as the latest; the script pins that value in one constant so a future version change is a one-line edit you make deliberately, not a surprise.
import os
import requests
NOTION_TOKEN = os.environ["NOTION_TOKEN"] # ntn_... personal access token or connection token
DATABASE_ID = os.environ["NOTION_DATABASE_ID"] # the 32-character ID from the database URL
headers = {
"Authorization": f"Bearer {NOTION_TOKEN}",
"Notion-Version": "2026-12-01",
}
db = requests.get(f"https://api.notion.com/v1/databases/{DATABASE_ID}", headers=headers, timeout=30)
db.raise_for_status()
for ds in db.json()["data_sources"]:
print(ds["id"], ds["name"]) # use this id as parent.data_source_idProperty mapping: which X field goes where
Notion stores each database row as a page whose properties follow the data source schema. The table below is the mapping the script uses, with the Notion value shape from the page property values reference and the fill rate we measured on 630 real posts. A low fill rate is not a bug: it tells you which columns will look sparse on the board.
Select options create themselves. Per the property values reference, writing a select or multi-select value by a name that does not exist yet adds the option to the schema, if your connection can write to the data source. So the Language and Hashtags columns grow as new values appear. Option names cannot contain commas, so the script replaces any comma in a hashtag with a space.
Store the ID as text, not a number. X post IDs are 19-digit integers, larger than a double-precision float can hold exactly. Our API returns id as a string; keep it a string in a text property and compare strings when deduping.
Keep the link. 45.6% of posts in the sample carried at least one link in entities.urls. If links matter to your research, add a second URL property for the first expanded link; the script leaves it out to stay short.
Numbers age. likeCount and viewCount are a snapshot at collection time. A post saved within its first hour shows a fraction of the likes it ends with. If you sort the board by engagement, either save posts a day late or refresh the two number properties with a later PATCH on the page.
What a week of a keyword board looks like: our measurement
To size the board before building it, we ran the exact search the script uses, one UTC day at a time, for seven consecutive days: ("notion ai" OR "notion template" OR "notion api") -filter:retweets, queryType=Latest, following next_cursor until has_next_page was false. Every post the search returned is one page the script would create.
The week produced 630 posts from 435 distinct authors: a mean of 90 new Notion pages a day, ranging from 76 to 117. That is a comfortable volume for a human to skim, which is the point of a research board. A single brand name with a large following can be ten or a hundred times that, so run one day of your own query before you point it at a shared workspace.
The language mix was the surprise. Japanese posts slightly outnumbered English ones, mainly through the phrase notion template. If your board is for one market, add lang:en (or your language) to the query rather than filtering in Notion: the posts you exclude in the query are posts you do not pay for and do not write.
Filtering by engagement is a query choice too. Only 28.9% of posts had 5 or more likes when collected. Adding min_faves:5 to the query would shrink the board to roughly that share, with the caveat above that young posts are still collecting likes.

Dedupe by tweet ID without hitting Notion's 10,000-result cap
Duplicates come from three places: a scheduled run that overlaps the previous one, a manual re-run after a failure, and two queries on one board that match the same post. Our pagination within each day returned 0 duplicate IDs, so the risk is between runs, not inside one. To measure it, after the week we re-polled the same query with no time window: it returned 40 posts, and all 40 (100%) were already on the board. Without the dedupe step, that re-run would have created 40 duplicate rows.
Read only the window you are about to write. The tempting version reads every Tweet ID on the board at start-up. That stops working as the board grows: a data source query returns pages of up to 100 results (the documented maximum page_size for list endpoints), and the query reference notes a 10,000-result cap after which has_more turns false. At 90 pages a day a board passes 10,000 rows in under four months. The script instead filters the query on the Posted date property ({"property": "Posted", "date": {"on_or_after": since}}), so it reads only rows from the window it is about to fill: about one query page per day of window.
Mind the separate query budget. Notion's request limits page says querying a data source has its own limit of about 3 requests per second per connection, on top of the general average. One query page per run is far inside it.
One query per post is the slow alternative. A rich_text equals filter on Tweet ID per post is correct but doubles the request count. Keep it as a fallback for a one-off import into an old board, not for the scheduled path.
Add a local memory if you run often. For runs every few minutes, keep a small file of IDs written in the last day next to the script and check it first; the Notion query then only guards against what the file missed (a crash after a write, a second machine).
Long posts and Notion's 2,000-character limit
Notion's request limits cap a rich text object's text.content at 2,000 characters, and an over-limit value fails the whole request with a validation_error and HTTP 400. X accepts long posts, and our API returns the full text in text, so this is not a theoretical edge case.
In the sample, the median post was 240 characters, 40.6% were longer than the classic 280, the 95th percentile was 2,494 characters, and 56 posts (8.9%) were over 2,000. The longest was 11,084 characters. A script that writes text into one rich text object would have failed on about one post in eleven.
The fix is chunking. The title property gets the first 100 characters (a readable row label). The full text goes into the page body as paragraph blocks of up to 1,900 characters each: the docs state the 2,000 limit in characters without saying how emoji and other multi-unit characters count, so the script leaves 100 characters of headroom. The longest sample post becomes 6 blocks. children accepts up to 100 blocks per request, which is room for about 190,000 characters, well beyond any post.
Payload limits are generous here. A request may carry up to 1,000 block elements and 500KB in total, and arrays (including rich text arrays and multi-select options) up to 100 elements. A single post never comes close; the script still trims hashtags to 100 as a guard.

Pacing writes: Notion's rate limit decides the speed
Notion's request limits page sets an average of 3 requests per second per connection for workspaces outside the Business and Enterprise plans, and an average of 10 per second on those plans, counted over a 60-second window. Over the limit, Notion answers HTTP 429 with the error code rate_limited and a Retry-After header holding a whole number of seconds (the body repeats it as additional_data.retry_after).
At 90 new pages a day, the write side needs about 30 seconds at 3 requests per second, so there is no reason to push it. The script waits a fixed 0.35 seconds after each Notion call, which keeps it just under the average, and on a 429 sleeps for exactly the Retry-After value before retrying the same request. The X side is not the bottleneck: paid TwitterAPI.io accounts get 20 requests per second, and one day of this board was 5 to 7 search pages.
Batch the run, not the request. Notion has no bulk create for pages, so 90 posts are 90 POST https://api.notion.com/v1/pages calls. Running the script once a day (or once an hour) keeps those calls in one predictable burst you can log and retry, instead of a trickle that is hard to audit.
What it costs, and how often to run it
TwitterAPI.io bills 15 credits per post returned, $0.15 per 1,000 posts, with a 15-credit ($0.00015) minimum per request; there is no per-request cap. A daily run of this board read 5 to 7 pages, the last one empty, and cost $0.0116 to $0.0177 a day, a mean of about $0.014. That is $0.41 for a 30-day month of about 2,700 posts. The same posts on the official X API, at $0.005 per post read on its pay-per-usage rate card, come to $13.50 a month, about 33 times more.
Hourly costs about the same. Because the board posts something almost every hour (only 6 of 144 hours on the six full days were empty, and no hour held more than 8 posts), an hourly run pays almost only for posts, plus the $0.00015 minimum on the few empty hours. Choose the schedule by how fresh the board must be, not by price. For minute-level freshness on a busy query, polling every minute costs at least $6.48 a month in empty checks alone (43,200 checks at the minimum), and a pushed filter rule is the better tool.
Notion side. Notion's request limits page describes rate and size limits, not per-call charges; your Notion plan governs the workspace. New TwitterAPI.io accounts get free starter credits (no card, one per person or network, expiring after 31 days); see the pricing page for the amount and the paid tiers.
How we collected this
Question. If a team fed a Notion research board from an X keyword search for one week, how many pages would it create per day, how many would dedupe skip, how full would each property be, how many posts would break Notion's 2,000-character limit, and what would the X data cost?
Query and endpoint. ("notion ai" OR "notion template" OR "notion api") -filter:retweets on /twitter/tweet/advanced_search, queryType=Latest, one request series per UTC day using since_time: and until_time:, following next_cursor until has_next_page was false. Then one re-poll of the same query with no window (2 pages).
Window and sample. Seven consecutive UTC days, collected in 2026; the seventh day was collected under an hour before it ended, so its count is slightly low if anything. 630 posts from 435 authors. The study used 48 requests (including 4 one-page probes to size the query) and 750 returned posts, about $0.11 in credits.
What the sample cannot show. It is one query in one week, so it says nothing about seasonality or about busier brand names. Engagement counts are a snapshot at collection time. We did not write to Notion: the Notion figures (seconds of writing, chunks per post, query pages) are computed from the documented limits, not observed.
Privacy. The search returns posts by private individuals, so we keep aggregates only: raw pages stayed out of the repository, the committed sample holds de-identified rows (day, hour, language, length, counts, flags) with no post ID, URL, text, author ID or handle, and no account is named or profiled.
"""Twitter (X) -> Notion: one Notion page per post from an X search, deduped by tweet ID.
Env: TWITTERAPI_IO_KEY, NOTION_TOKEN, NOTION_DATABASE_ID
Database properties: Name (title), Tweet ID (text), URL (url), Author (text), Posted (date),
Language (select), Likes (number), Views (number), Has media (checkbox), Hashtags (multi-select).
"""
import os
import time
from datetime import datetime, timezone
import requests
BASE = "https://api.twitterapi.io"
NOTION_VERSION = "2026-12-01" # pin the version you tested against
QUERY = '("notion ai" OR "notion template" OR "notion api") -filter:retweets'
WINDOW_HOURS = 24
CHUNK = 1900 # under the 2,000-character rich_text limit
NOTION_PAUSE = 0.35 # fixed pacing, under an average of 3 requests/s
x = requests.Session()
x.headers["X-API-Key"] = os.environ["TWITTERAPI_IO_KEY"]
notion = requests.Session()
notion.headers.update({
"Authorization": f"Bearer {os.environ['NOTION_TOKEN']}",
"Notion-Version": NOTION_VERSION,
"Content-Type": "application/json",
})
def notion_call(method, url, body=None):
"""One Notion request with fixed pacing; on 429 wait exactly Retry-After seconds."""
for _ in range(5):
r = notion.request(method, url, json=body, timeout=30)
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", "1")))
continue
if r.status_code >= 400:
raise RuntimeError(f"Notion {r.status_code}: {r.text[:300]}")
time.sleep(NOTION_PAUSE)
return r.json()
raise RuntimeError("Notion kept answering 429")
def data_source_id():
db = notion_call("GET", f"https://api.notion.com/v1/databases/{os.environ['NOTION_DATABASE_ID']}")
return db["data_sources"][0]["id"]
def search_x(since_ts, until_ts):
"""Yield every post in the window, following next_cursor."""
params = {
"query": f"{QUERY} since_time:{since_ts} until_time:{until_ts}",
"queryType": "Latest",
"cursor": "",
}
while True:
r = x.get(f"{BASE}/twitter/tweet/advanced_search", params=params, timeout=30)
r.raise_for_status()
body = r.json()
for tweet in body.get("tweets", []):
yield tweet
if not body.get("has_next_page") or not body.get("next_cursor"):
return
params["cursor"] = body["next_cursor"]
def saved_ids(ds_id, since_iso):
"""Tweet IDs already on the board for this window (date filter keeps it small)."""
ids, cursor = set(), None
while True:
query = {"page_size": 100,
"filter": {"property": "Posted", "date": {"on_or_after": since_iso}}}
if cursor:
query["start_cursor"] = cursor
res = notion_call("POST", f"https://api.notion.com/v1/data_sources/{ds_id}/query", query)
for page in res["results"]:
rich = page["properties"]["Tweet ID"]["rich_text"]
if rich:
ids.add(rich[0]["plain_text"])
if not res.get("has_more"):
return ids
cursor = res["next_cursor"]
def text_obj(s):
return [{"type": "text", "text": {"content": s}}]
def to_page(ds_id, t):
author = t.get("author") or {}
text = t.get("text") or ""
posted = datetime.strptime(t["createdAt"], "%a %b %d %H:%M:%S %z %Y").isoformat()
tags = [h["text"].replace(",", " ") for h in (t.get("entities") or {}).get("hashtags") or [] if h.get("text")]
props = {
"Name": {"title": text_obj(text[:100] or t["id"])},
"Tweet ID": {"rich_text": text_obj(t["id"])},
"URL": {"url": t.get("url")},
"Author": {"rich_text": text_obj("@" + author.get("userName", ""))},
"Posted": {"date": {"start": posted}},
"Language": {"select": {"name": t.get("lang") or "und"}},
"Likes": {"number": t.get("likeCount", 0)},
"Views": {"number": t.get("viewCount")},
"Has media": {"checkbox": bool((t.get("extendedEntities") or {}).get("media"))},
"Hashtags": {"multi_select": [{"name": tag} for tag in dict.fromkeys(tags)][:100]},
}
chunks = [text[i:i + CHUNK] for i in range(0, len(text), CHUNK)]
children = [{"object": "block", "type": "paragraph", "paragraph": {"rich_text": text_obj(c)}}
for c in chunks[:100]]
return {"parent": {"data_source_id": ds_id}, "properties": props, "children": children}
def run():
ds_id = data_source_id()
until_ts = int(time.time())
since_ts = until_ts - WINDOW_HOURS * 3600
since_iso = datetime.fromtimestamp(since_ts, timezone.utc).isoformat()
have = saved_ids(ds_id, since_iso)
created = skipped = 0
for tweet in search_x(since_ts, until_ts):
if tweet["id"] in have:
skipped += 1
continue
notion_call("POST", "https://api.notion.com/v1/pages", to_page(ds_id, tweet))
have.add(tweet["id"])
created += 1
print(f"created {created} Notion pages, skipped {skipped} already on the board")
if __name__ == "__main__":
run()
Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.
Questions readers ask
Does Notion have a built-in Twitter (X) integration?
We found no native connector that pulls X posts into a Notion database on a schedule; the options in search results are an automation platform template (Zapier, Make, IFTTT and similar) or a script like the one on this page that reads X data through an API and calls Notion's POST https://api.notion.com/v1/pages.
How do I save tweets to a Notion database automatically?
Create a database with a title property plus a Tweet ID text property, share it with a Notion connection (or use a personal access token), then run a script on a schedule that searches X with /twitter/tweet/advanced_search, skips IDs the board already holds, and creates one page per new post with parent.data_source_id. Cron, a GitHub Actions schedule or any always-on machine can run it.
How do I stop the same tweet being added twice?
Store each post's ID in a text property and check it before writing. The script reads the IDs already saved for the run's time window with one data source query filtered on the Posted date, then skips matches. In our test, a re-poll returned 40 posts and all 40 were already on the board, so dedupe saved 40 duplicate rows.
Why does Notion reject some tweets with a validation_error?
A rich text object's content is limited to 2,000 characters, and long X posts exceed it. In our one-week sample, 8.9% of posts were longer than 2,000 characters and the longest was 11,084. Split the text into chunks (the script uses 1,900 characters) and write them as paragraph blocks in the page body; keep the title short.
What is the Notion API rate limit?
Per Notion's request limits page, an average of 3 requests per second per connection on non-Business plans and an average of 10 on Business and Enterprise, counted over 60 seconds, with a separate limit of about 3 per second for data source queries. Over the limit you get HTTP 429 with a Retry-After header in seconds.
Do I need an X developer account or my own X login?
Not for this integration. Reading public posts through TwitterAPI.io needs only an API key in the X-API-Key header, no X account. A login session is needed only for write actions on X (posting, liking, following), which this board never does.
How much does it cost to send a keyword's tweets to Notion?
On the X side, $0.15 per 1,000 posts returned with a $0.00015 minimum per request. Our measured board (about 90 posts a day) cost about $0.014 a day, $0.41 a month. The official X API at $0.005 per post read would charge about $13.50 a month for the same posts. Notion's API docs describe rate and size limits, not per-call charges; your Notion plan covers the workspace.
Can I save my X bookmarks to Notion the same way?
Bookmarks are private, so they need an authenticated route rather than a public search. Our X bookmarks AI guide covers exporting them; the Notion half of this page (property mapping, dedupe, chunking) then works unchanged.
Continue
- Notion API reference: Create a page (POST https://api.notion.com/v1/pages, data_source_id parent, Notion-Version header, children limit)
- Notion API reference: Request limits (average 3 requests/s per connection, 10 on Business and Enterprise, 429 and Retry-After, 2,000-character rich text)
- Notion API reference: Page property values (title, rich_text, number, url, date, select, multi_select, checkbox)
- Notion API reference: Query a data source (filter, start_cursor, has_more, 10,000-result cap)
- TwitterAPI.io API reference: Advanced Search (query, queryType, cursor, since_time and until_time)
- X API pay-per-usage pricing ($0.005 per post read), the official route
- X API overview: endpoints, pricing and limits
- Export X bookmarks to Notion, Obsidian or an AI assistant
- Twitter Airtable integration in code
- Pull Twitter (X) data into Google Sheets
- n8n workflow for Twitter (X) data without code
- Twitter (X) data in Excel with the API
- Keyword alerts for Twitter (X): a developer guide
- TwitterAPI.io pay-per-use pricing and free starter credits
- 01How to Mute a Conversation on Twitter (X): Mute This Conversation, Step by Step
- 02How to Hide Replies on Twitter (X), and What a Hidden Reply Still Shows
- 03Twitter (X) Ad Examples by Format, With Real Brand Data
- 04Twitter (X) Affiliate Marketing in 2026: Rules, Disclosure and What Link Posts Really Reach
- 05Tweets to CSV: Export Twitter (X) Posts to a Clean CSV File
- 06Twitter (X) in Looker Studio: Build the Dashboard Without a Paid Connector
- 07Twitter (X) Creator Subscriptions API: see which creators an account subscribes to
- 08How to Track Andrew Tate's Tweets Using the Twitter (X) API
Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.
Stop reading. Start building.
Starter credits cover real testing on real data. Google sign-in, no card, no application queue.
Get an API keyAlready building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.