Creating session tokens - zedeus/nitter GitHub Wiki

Warning

Running a large public instance is difficult, and is not feasible with a small amount of accounts. If you'd like to run one, consider reaching out to @zedeus:nolog.chat (Matrix) or [email protected] (email) for assistance with getting started.

Nitter requires real accounts to authenticate API requests. The sessions are loaded from sessions.jsonl in the directory where the nitter binary is. You can overwrite this by setting the environment variable NITTER_SESSIONS_FILE.

JSONL, aka NDJSON, is the only supported format. The filename must end in .jsonl. The file should look like this:

{"kind": "cookie", "auth_token": "...", "ct0": "...", "username": "...", "id": "..."}
{"kind": "cookie", "auth_token": "...", "ct0": "...", "username": "...", "id": "..."}

Note that username and id are optional, but they make it easier to troubleshoot and monitor your sessions.

Using create_session_browser.py

To create a session, use the create_session_browser.py script in the tools/ directory:

pip install -r requirements.txt
python3 create_session_browser.py <username> <password> [totp_secret] --append ../sessions.jsonl

The script handles 2FA automatically if a TOTP secret is provided. The secret is the base32 string provided by x.com during 2FA setup, accessible by clicking "can't scan" on the QR code page. If you already have 2FA setup, copy the secret from your authenticator app, or disable 2FA and set it up again.

You can now run Nitter and should see:

[sessions] Parsing JSONL account sessions file: ./sessions.jsonl
[sessions] Successfully added 1 valid account sessions.

For multiple accounts, simply run the script again. It's a good idea to use proxies/VPNs if creating many sessions, but it's unknown how much this affects your risk of getting banned.

Using create_session_curl.py

An alternative script is available that uses HTTP requests instead of browser automation:

pip install -r requirements.txt
python3 create_session_curl.py <username> <password> [totp_secret] --append ../sessions.jsonl

This script is much faster than create_session_browser.py, since it uses curl_cffi to make requests rather than full browser automation. However, this method may be more susceptible to bot detection, so it's recommend to only use this if speed is a priority or the other script isn't working.

⚠️ **GitHub.com Fallback** ⚠️