Truth Social 的 API 客户端
Truthbrush is an API client for Truth Social.
Currently, this tool can:
Truthbrush is designed for academic research, open source intelligence gathering, and data archival. It pulls all data from the publicly accessible API.
From PyPi:
pip install truthbrushFrom git:
pip install git+https://github.com/stanfordio/truthbrush.gitFrom source:
pip3 install .. Provided your pip is setup correctly, this will make truthbrush available both as a command and as a Python package.After installation, you will need to set your Truth Social username and password as environmental variables.
export TRUTHSOCIAL_USERNAME=foo
export TRUTHSOCIAL_PASSWORD=bar
If you encounter login issues, you can instead extract your login token from the truth:auth Local Storage store and export it in TRUTHSOCIAL_TOKEN.
You may also set these variables in a .env file in the directory from which you are running Truthbrush.
Some Truth Social endpoints are readable without authentication. To run Truthbrush against only those endpoints, pass --no-auth on the CLI or construct the client with require_auth=False:
truthbrush --no-auth trends
truthbrush --no-auth user realDonaldTrumpfrom truthbrush import Api
api = Api(require_auth=False)
print(api.trending())Endpoints that require authentication will return an API error (typically HTTP 401) when called in public mode. Which endpoints are publicly accessible is determined by Truth Social and may change without notice.
…Search for users, statuses, groups, or hashtags
truthbrush search --searchtype [accounts|statuses|hashtags|groups] QUERYRestrict status results to a date window:
truthbrush search --searchtype statuses --start-date 2024-11-01 --end-date 2024-11-07 QUERYPull all statuses (posts) from a user
truthbrush statuses HANDLERestrict to a date window (UTC assumed when no timezone is given):
truthbrush statuses --created-after 2024-11-01 --created-before 2024-11-07 HANDLEPull "People to Follow" (suggested) users
truthbrush suggestionsPull trendy tags
truthbrush tagsPull ads
truthbrush adsPull all of a user's metadata
truthbrush user HANDLEPull the list of users who liked a post
truthbrush likes POST --includeall TOP_NUMPull the list of oldest comments on a post
truthbrush comments POST --includeall --onlyfirst TOP_NUMPull trending group tags
truthbrush grouptagsPull trending groups
truthbrush grouptrendsPull list of suggested groups
truthbrush groupsuggestionsPull posts from a group's timeline
truthbrush groupposts GROUP_IDContributions are encouraged! For small bug fixes and minor improvements, feel free to just open a PR. For larger changes, please open an issue first so that other contributors can discuss your plan, avoid duplicated work, and ensure it aligns with the goals of the project. Be sure to also follow the code of conduct. Thanks!
Development setup (ensure you have Poetry installed):
poetry install
poetry shell
truthbrush --help # will use your local copy of truthbrushTo run the tests:
pytest
# optionally run tests with verbose logging outputs:
pytest --log-cli-level=DEBUG -sPlease format and lint your code with ruff, and run ty to check types:
ruff format .
ruff check .
ty check truthbrush/暂无开放 Issues,或尚未同步最近议题。