MCPcopy Index your code
hub / github.com/DocNow/twarc

github.com/DocNow/twarc @v2.14.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.14.1 ↗ · + Follow
397 symbols 1,623 edges 61 files 181 documented · 46%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

twarc

Note: twarc is no longer actively supported after changes to Twitter's API quotas made it unusable.


DOI

twarc is a command line tool and Python library for collecting and archiving Twitter JSON data via the Twitter API. It has separate commands (twarc and twarc2) for working with the older v1.1 API and the newer v2 API and Academic Access (respectively).

twarc has been developed with generous support from the Mellon Foundation.

Contributing

New features are welcome and encouraged for twarc. However, to keep the core twarc library and command line tool sustainable we will look at new functionality with the following principles in mind:

  1. Purpose: twarc is for collection and archiving of Twitter data via the Twitter API.
  2. Sustainability: keeping the surface area of twarc and it's dependencies small enough to ensure high quality.
  3. Utility: what is exposed by twarc should be applicable to different people, projects and domains, and not specific use cases.
  4. API consistency: as much as sensible we aim to make twarc consistent with the Twitter API, and also aim to make twarc consistent with itself - so commands in core twarc should work similarly to each other, and twarc functionality should align towards the Twitter API.

For features and approaches that fall outside of this, twarc enables external packages to hook into the twarc2 command line tool via click-plugins. This means that if you want to propose new functionality, you can create your own package without coordinating with core twarc.

Documentation

The documentation is managed at ReadTheDocs. If you would like to improve the documentation you can edit the Markdown files in docs or add new ones. Then send a pull request and we can add it.

To view your documentation locally you should be able to:

pip install -r requirements-mkdocs.txt
pip install -e .
mkdocs serve
open http://127.0.0.1:8000/

If you prefer you can create a page on the wiki to workshop the documentation, and then when/if you think it's ready to be merged with the documentation create an issue. Please feel free to create whatever documentation is useful in the wiki area.

Code

If you are interested in adding functionality to twarc or fixing something that's broken here are the steps to setting up your development environment:

git clone https://github.com/docnow/twarc
cd twarc

Create a .env file that included Twitter App keys to use during testing:

BEARER_TOKEN=CHANGEME
CONSUMER_KEY=CHANGEME
CONSUMER_SECRET=CHANGEME
ACCESS_TOKEN=CHANGEME
ACCESS_TOKEN_SECRET=CHANGEME

Now run the tests:

uv run pytest

Add your code and some new tests, and send a pull request!

Core symbols most depended-on inside this repo

get
called by 45
src/twarc/client.py
get
called by 44
utils/oembeds.py
search
called by 26
src/twarc/client.py
_process_expansions_shortcuts
called by 23
src/twarc/command2.py
connect
called by 19
src/twarc/client.py
_write
called by 19
src/twarc/command2.py
timeline
called by 18
src/twarc/client.py
_prepare_params
called by 18
src/twarc/client2.py

Shape

Function 257
Method 106
Route 20
Class 14

Languages

Python100%

Modules by API surface

src/twarc/command2.py86 symbols
test_twarc.py59 symbols
src/twarc/client2.py50 symbols
test_twarc2.py37 symbols
src/twarc/client.py31 symbols
src/twarc/decorators2.py26 symbols
src/twarc/json2csv.py16 symbols
utils/media2warc.py14 symbols
src/twarc/decorators.py7 symbols
utils/extractor.py6 symbols
utils/deletes.py6 symbols
utils/oembeds.py5 symbols

For agents

$ claude mcp add twarc \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact