Skip to content

Creating session tokens

Zed edited this page Feb 24, 2025 · 4 revisions

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:

{"oauth_token": "...", "oauth_token_secret": "..."}
{"oauth_token": "...", "oauth_token_secret": "..."}
{"oauth_token": "...", "oauth_token_secret": "..."}

To create a session, you can use the get_session.py script in this repo. Note that this script assumes the account has 2FA enabled, which is strongly recommended.

# assuming you're in the root nitter folder
cd tools
python3 -m venv venv && source venv/bin/activate # optional
pip install pyotp requests
python get_session.py <username> <password> <2fa secret> ../sessions.jsonl

2fa secret refers to the secret used to generate OTP tokens. This is provided by Twitter during the 2FA setup, where you can copy it by clicking "can't scan" on the QR code page. If you already have 2FA setup, you can either grab the secret from your OTP app/extension/etc, or you can disable 2FA and set it up again.

You can now run Nitter, and you should see the following:

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

If you have more than one account, you can run the script again, though it's recommended to run this through a proxy/VPN if you're planning to create many sessions.

nitter

Clone this wiki locally