Twitter (X) Lists API — Programmatic Guide

By Alex Chen•9 min read
TL;DR
  • GET /twitter/list/tweets?listId=<id> returns 20 tweets per page, newest first, with optional sinceTime, untilTime and includeReplies
  • GET /twitter/list/members?list_id=<id> and GET /twitter/list/followers?list_id=<id> return 20 accounts per page
  • Parameter casing differs: listId on the two tweet endpoints, list_id on members and followers
  • Adding or removing List members is not a documented twitterapi.io endpoint; use the official X API (POST /2/lists/{id}/members, DELETE /2/lists/{id}/members/{user_id}) at $0.005 per request
  • No twitterapi.io endpoint creates a List, returns List metadata or returns a user's List memberships; use the X app or the official X API for those
  • Price: $0.00015 per tweet, $0.00018 per member or follower (twitterapi.io/pricing)

An X List is a named set of accounts. Reading a List gives you the tweets of exactly those accounts in one call, so a List is a convenient unit for monitoring: you choose the accounts once, in the X app, and your code only needs the List ID.

This guide covers what twitterapi.io can do with a List and what it cannot. It can read a List's tweets, members and followers, which is the high-volume part of most List projects. It does not currently document an endpoint to add or remove members, create a List, return a List's name or counts, or tell you which Lists an account belongs to. For those, the guide points to the X app and the official X API, with a working member-management script. All parameter names, response fields and page sizes below come from the twitterapi.io API reference.

List read prices on twitterapi.io

$0.00015 per tweet and $0.00018 per member or follower returned, 20 items per page, per twitterapi.io/pricing

01 — Section

What you can and cannot do with Lists on twitterapi.io

Tasktwitterapi.ioWhere to do it otherwise
Read the tweets of a ListGET /twitter/list/tweets, GET /twitter/list/tweets_timeline
Read the members of a ListGET /twitter/list/members
Read the followers (subscribers) of a ListGET /twitter/list/followers
Add a memberNot a documented endpointX app, or official X API POST /2/lists/{id}/members
Remove a memberNot a documented endpointX app, or official X API DELETE /2/lists/{id}/members/{user_id}
Create or delete a ListNot availableX app, or official X API POST /2/lists and DELETE /2/lists/{id}
Read List metadata (name, description, counts, owner)Not availableOfficial X API GET /2/lists/{id}
Find the Lists a user is a member ofNot availableOfficial X API GET /2/users/{id}/list_memberships

The practical consequence: you need a List ID before you can call anything. The ID is the number at the end of the List URL in the X app, for example x.com/i/lists/1846987139428634858.

The read endpoints accept an API key and a List ID and nothing else. The API reference does not describe any way to read a private List, so plan around public Lists.

In short: twitterapi.io is the read side. Anything that changes a List, including its membership, goes through the X app or the official X API.

02 — Section

Read endpoints: tweets, members, followers

All four read endpoints are GET requests to https://api.twitterapi.io with the header X-API-Key.

EndpointParametersReturnsPage size
/twitter/list/tweetslistId (required), sinceTime, untilTime, includeReplies, cursortweets, has_next_page, next_cursor, status, msg20 tweets, newest first
/twitter/list/tweets_timelinelistId (required), cursortweets, has_next_page, next_cursorNot stated in the reference
/twitter/list/memberslist_id (required), cursormembers, has_next_page, next_cursor, status, msg20 accounts
/twitter/list/followerslist_id (required), cursorfollowers, has_next_page, next_cursor, status, msg20 accounts

Mind the parameter casing. The two tweet endpoints take listId in camelCase. Members and followers take list_id in snake_case. Sending the wrong form is the most likely reason for a failed first call. The error text is in msg on all four read endpoints.

Time filters. sinceTime and untilTime on /twitter/list/tweets are Unix timestamps in seconds. sinceTime means on or after, untilTime means before. includeReplies defaults to true. /twitter/list/tweets_timeline has no time filters, so use /twitter/list/tweets when you poll for new tweets.

Pagination. Send cursor as an empty string for the first page, then pass next_cursor while has_next_page is true. The reference warns that has_next_page on /twitter/list/tweets can be true when nothing is left, in which case the next page comes back empty. Stop on an empty page as well as on has_next_page being false.

Tweet fields. Each tweet carries id, url, text, createdAt, lang, likeCount, retweetCount, replyCount, quoteCount, viewCount, bookmarkCount, isReply and an author object.

Account fields. Members and followers use the same user object as author: id, userName, name, followers, following, isBlueVerified, description, location, createdAt, statusesCount and more.

03 — Section

Runnable: monitor the tweets of a List

This script polls one List every 15 minutes, asks only for tweets since the last poll with sinceTime, and prints tweets that contain a keyword and pass an engagement threshold. It stores the last poll time and the tweet IDs it has already handled in a local file.

You pay for the tweets returned, so a poll that asks only for new tweets costs less than re-reading the first pages every time. A poll that returns nothing is charged the minimum of $0.00015.

python
import json
import os
import time
from pathlib import Path

import requests

BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]}

LIST_ID = os.environ["WATCH_LIST_ID"]  # the number at the end of the List URL
KEYWORD = "pricing"                    # word to look for in list tweets
MIN_ENGAGEMENT = 20                    # likes + retweets
POLL_SECONDS = 900                     # one poll every 15 minutes
MAX_PAGES = 10                         # safety cap: 10 pages = 200 tweets per poll

STATE = Path(".state/list_monitor.json")
STATE.parent.mkdir(exist_ok=True)


def load_state() -> dict:
    if STATE.exists():
        return json.loads(STATE.read_text())
    # first run: look back one poll interval
    return {"since": int(time.time()) - POLL_SECONDS, "seen": []}


def save_state(state: dict) -> None:
    state["seen"] = state["seen"][-2000:]
    STATE.write_text(json.dumps(state))


def list_tweets_since(list_id: str, since_time: int) -> list:
    """All list tweets created on or after since_time (Unix seconds)."""
    tweets, cursor = [], ""
    for _ in range(MAX_PAGES):
        r = requests.get(
            f"{BASE}/twitter/list/tweets",
            headers=HEADERS,
            params={"listId": list_id, "sinceTime": since_time, "cursor": cursor},
            timeout=30,
        )
        r.raise_for_status()
        data = r.json()
        if data.get("status") == "error":
            raise RuntimeError(data.get("msg"))
        page = data.get("tweets") or []
        if not page:  # has_next_page can be true with nothing left
            break
        tweets.extend(page)
        cursor = data.get("next_cursor") or ""
        if not data.get("has_next_page") or not cursor:
            break
    return tweets


def poll_once() -> None:
    state = load_state()
    seen = set(state["seen"])
    started = int(time.time())

    tweets = list_tweets_since(LIST_ID, state["since"])
    new = [t for t in tweets if t["id"] not in seen]
    print(f"{len(new)} new tweets ({len(tweets)} returned)")

    for t in new:
        engagement = (t.get("likeCount") or 0) + (t.get("retweetCount") or 0)
        if KEYWORD in (t.get("text") or "").lower() and engagement >= MIN_ENGAGEMENT:
            author = (t.get("author") or {}).get("userName", "?")
            print(f"  @{author} ({engagement}): {t.get('url')}")

    state["seen"].extend(t["id"] for t in new)
    state["since"] = started - 60  # one minute of overlap; 'seen' removes repeats
    save_state(state)


while True:
    try:
        poll_once()
    except Exception as exc:
        print(f"poll failed: {exc}")
    time.sleep(POLL_SECONDS)
04 — Section

Add and remove List members (official X API)

Managing List membership is not currently a documented twitterapi.io endpoint. The twitterapi.io API reference documents List reads only, so this guide does not point you at any twitterapi.io write route for Lists. To add or remove members from code, use the official X API. Paths and auth below are from docs.x.com.

OperationOfficial X APIBody or path parametersAuth (docs.x.com)
Add a memberPOST /2/lists/{id}/membersList id in the path, JSON body {"user_id": "<numeric id>"}User context; OAuth 2.0 needs the list.write scope
Remove a memberDELETE /2/lists/{id}/members/{user_id}List id and the member's numeric user_id in the pathUser context; OAuth 2.0 needs the list.write scope

Who can do it. The token has to belong to the account that owns the List. That means a developer account with the X API, an app, and an OAuth flow for that account.

Price. The X pricing page lists List: Manage at $0.005 per request on pay-per-use.

Handles to IDs. Both X endpoints take the numeric user ID, not the handle. If you start from handles, GET /twitter/user/info?userName=<handle> on twitterapi.io returns the ID in data.id with only an API key.

No code at all. For a few accounts, adding them by hand in the X app is the shortest route. The official API is worth the setup when membership changes are frequent or driven by your own data.

The script below combines the two: it looks up IDs with twitterapi.io, then adds and removes members with the official X API. It waits a few seconds between writes as a cautious default, not a documented number; check the rate limits on docs.x.com for your access level.

python
import os
import time

import requests

# Read side: twitterapi.io (API key only) turns a handle into a numeric user ID.
TWITTERAPI_BASE = "https://api.twitterapi.io"
TWITTERAPI_HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]}

# Write side: official X API, user context. The token needs the list.write scope
# and must belong to the account that owns the List.
X_BASE = "https://api.x.com/2"
X_HEADERS = {"Authorization": f"Bearer {os.environ['X_USER_ACCESS_TOKEN']}"}

LIST_ID = os.environ["WATCH_LIST_ID"]  # a List the token's account owns


def user_id_for(handle: str) -> str:
    r = requests.get(
        f"{TWITTERAPI_BASE}/twitter/user/info",
        headers=TWITTERAPI_HEADERS,
        params={"userName": handle},
        timeout=30,
    )
    r.raise_for_status()
    data = r.json()
    if data.get("status") != "success":
        raise RuntimeError(data.get("msg"))
    return data["data"]["id"]


def add_list_member(list_id: str, user_id: str) -> None:
    r = requests.post(
        f"{X_BASE}/lists/{list_id}/members",
        headers=X_HEADERS,
        json={"user_id": user_id},
        timeout=30,
    )
    r.raise_for_status()


def remove_list_member(list_id: str, user_id: str) -> None:
    r = requests.delete(
        f"{X_BASE}/lists/{list_id}/members/{user_id}",
        headers=X_HEADERS,
        timeout=30,
    )
    r.raise_for_status()


TO_ADD = ["stripe", "paypal", "adyen"]
TO_REMOVE = ["square"]

for name in TO_ADD:
    try:
        add_list_member(LIST_ID, user_id_for(name))
        print(f"added @{name}")
    except Exception as exc:
        print(f"could not add @{name}: {exc}")
    time.sleep(5)  # spread the writes out

for name in TO_REMOVE:
    try:
        remove_list_member(LIST_ID, user_id_for(name))
        print(f"removed @{name}")
    except Exception as exc:
        print(f"could not remove @{name}: {exc}")
    time.sleep(5)
05 — Section

What twitterapi.io does not cover, and where to do it

Besides member changes (covered above), three more List operations are not in the twitterapi.io API. The official X API has all three. Paths and auth below are from docs.x.com.

OperationOfficial X APIAuth (docs.x.com)
Create a ListPOST /2/lists with name, optional description and privateUser context; OAuth 2.0 needs the list.write scope
Delete a ListDELETE /2/lists/{id}User context
List metadataGET /2/lists/{id}Bearer token or user context
Lists a user is a member ofGET /2/users/{id}/list_membershipsBearer token or user context

If you only need one or a few Lists, creating them by hand in the X app is the shortest route: no developer account, no OAuth. The official API is worth the setup when your product creates Lists for its own users.

A workable split for most monitoring projects: create the List and manage its members in the X app or with the official X API, then use twitterapi.io for the high-volume part, which is reading tweets, members and followers.

06 — Section

Cost of reading Lists

twitterapi.io bills per item returned. $1 buys 100,000 credits; a tweet costs 15 credits and a member or follower costs 18. Every call costs at least 15 credits, including a call that returns nothing. Figures are list prices from twitterapi.io/pricing.

Itemtwitterapi.ioOfficial X API pay-per-use (docs.x.com)
One tweet from a List$0.00015$0.005 per post read
One page of 20 tweets$0.003$0.10
1,000 tweets$0.15$5.00
One member or follower$0.00018$0.010 per user read
1,000 members$0.18$10.00
Add or remove a memberNot a documented endpoint$0.005 per request (List: Manage)
Create a ListNot available$0.010 per request (List: Create)

A worked example. One List polled every 15 minutes is 96 polls a day. If each poll returns one full page of 20 tweets, that is 1,920 tweets a day, or $0.288 a day and $8.64 over 30 days. A quiet List costs less, because you pay for tweets returned and the floor is $0.00015 per poll, about $0.43 over 30 days.

The X column is arithmetic on the per-resource prices on the X pricing page. That page also states a cap of 3 million post reads per monthly billing cycle on pay-per-use.

07 — Section

Practical notes

Use the right ID parameter. listId for tweets, list_id for everything else. Wrap the calls in two small helpers so the difference lives in one place.

Choose the poll interval from the List's activity. With 20 tweets per page, a busy List needs several pages per poll. sinceTime keeps each poll to the new tweets only.

Keep a list of seen tweet IDs. sinceTime is on-or-after, so overlapping polls return the boundary tweets twice. Deduplicate by id.

Member lists are paged at 20. A List with 1,000 members takes 50 calls to read in full. Cache the result and refresh it on a schedule instead of on every run.

A removed member's tweets are still reachable. After an account is removed from a List, its tweets no longer come back from the List endpoints. You can still read them with /twitter/user/last_tweets?userName=<handle>.

Compare members over time. There is no endpoint that reports membership changes. Export the members on a schedule and diff the id values to see who was added or removed.

python
# Export the members and followers of a List to CSV
import csv
import os

import requests

BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_KEY"]}
LIST_ID = os.environ["WATCH_LIST_ID"]
MAX_PAGES = 100  # 100 pages x 20 accounts = 2,000 accounts per export

FIELDS = ["id", "userName", "name", "followers", "following", "isBlueVerified", "createdAt"]


ENDPOINTS = {
    "members": f"{BASE}/twitter/list/members",
    "followers": f"{BASE}/twitter/list/followers",
}


def list_accounts(kind: str, list_id: str) -> list:
    """kind is 'members' or 'followers'. Note: list_id, not listId."""
    accounts, cursor = [], ""
    for _ in range(MAX_PAGES):
        r = requests.get(
            ENDPOINTS[kind],
            headers=HEADERS,
            params={"list_id": list_id, "cursor": cursor},
            timeout=30,
        )
        r.raise_for_status()
        data = r.json()
        if data.get("status") == "error":
            raise RuntimeError(data.get("msg"))
        page = data.get(kind) or []  # response key is "members" or "followers"
        if not page:
            break
        accounts.extend(page)
        cursor = data.get("next_cursor") or ""
        if not data.get("has_next_page") or not cursor:
            break
    return accounts


def write_csv(path: str, accounts: list) -> None:
    with open(path, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS, extrasaction="ignore")
        writer.writeheader()
        writer.writerows(accounts)


members = list_accounts("members", LIST_ID)
followers = list_accounts("followers", LIST_ID)
write_csv("list_members.csv", members)
write_csv("list_followers.csv", followers)

member_ids = {m["id"] for m in members}
both = [f["userName"] for f in followers if f["id"] in member_ids]
print(f"{len(members)} members, {len(followers)} followers, {len(both)} accounts are both")

# Cost at list price: 18 credits ($0.00018) per account returned,
# so 1,000 members cost $0.18. Minimum 15 credits per call.

Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.

08 — Questions

Questions readers ask

Can I create a Twitter (X) List through twitterapi.io?

No. twitterapi.io has no endpoint to create or delete a List. Create it in the X app, or with the official X API (POST /2/lists, per docs.x.com). Once the List exists, read its tweets, members and followers with twitterapi.io.

How do I get a List's name, description or member count?

twitterapi.io has no List metadata endpoint. The official X API returns it from GET /2/lists/{id}. If you only need the member count, page through /twitter/list/members and count the results.

How do I find the Lists a user is a member of?

Not with twitterapi.io; there is no memberships endpoint. The official X API has GET /2/users/{id}/list_memberships (docs.x.com).

Is it listId or list_id?

Both, depending on the endpoint. /twitter/list/tweets and /twitter/list/tweets_timeline take listId. /twitter/list/members and /twitter/list/followers take list_id.

How many items come back per call?

/twitter/list/tweets returns 20 tweets per page, newest first. /twitter/list/members and /twitter/list/followers return 20 accounts per page. Use cursor with next_cursor to read further pages.

Can I read a private List?

The API reference does not describe private-List access. The read endpoints take only an API key and a List ID, with no parameter for the owner's session, so plan around public Lists.

Can I add or remove List members with twitterapi.io?

Not currently: managing List membership is not a documented twitterapi.io endpoint. Use the X app, or the official X API: POST /2/lists/{id}/members with a user_id body to add and DELETE /2/lists/{id}/members/{user_id} to remove, with a user-context token that has the list.write scope (docs.x.com). The X pricing page lists List: Manage at $0.005 per request. twitterapi.io can still look up the numeric user IDs and read the List afterwards.

Can I get engagement numbers for a whole List?

Not in one call. Read the tweets with /twitter/list/tweets and sum likeCount, retweetCount, replyCount and quoteCount in your own code.

What is the difference between /twitter/list/tweets and /twitter/list/tweets_timeline?

/twitter/list/tweets is documented in more detail: 20 tweets per page, newest first, with sinceTime, untilTime and includeReplies filters. /twitter/list/tweets_timeline takes only listId and cursor, and the reference does not state its page size or order. Use /twitter/list/tweets for polling.

09 — Further reading

Continue

Sources & further reading
More from this series

Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.

Build it

Stop reading. Start building.

Starter credits cover real testing on real data. Google sign-in, no card, no application queue.

Get an API key

Already building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.