Skip to main content

API client for Truth Social

Project description

truthbrush

Truthbrush is an API client for Truth Social.

Currently, this tool can:

  • Search for users, statuses, groups, or hashtags
  • Pull a user's statuses
  • Pull the list of "People to Follow" or suggested users
  • Pull "trending" hashtags
  • Pull "trending" Truth posts
  • Pull ads
  • Pull a user's metadata
  • Pull the list of users who liked a post
  • Pull the list of comments on a post
  • Pull "trending" groups
  • Pull list of suggested groups
  • Pull "trending" group hashtags
  • Pull posts from group timeline

Truthbrush is designed for academic research, open source intelligence gathering, and data archival. It pulls all data from the publicly accessible API.

Installation

From PyPi:

pip install truthbrush

From git:

  • To install it, run pip install git+https://github.com/stanfordio/truthbrush.git

From source:

  • Clone the repository and run 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.

Public mode (no credentials)

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 realDonaldTrump
from 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.

CLI Usage

Usage: truthbrush [OPTIONS] COMMAND [ARGS]...

Options:
  --no-auth  Run without authentication. Only public endpoints will succeed.
  --help     Show this message and exit.


Commands:
  search            Search for users, statuses or hashtags.
  statuses          Pull a user's statuses.
  suggestions       Pull the list of suggested users.
  tags              Pull trendy tags.
  trends            Pull trendy Truths.
  ads               Pull ads.
  user              Pull a user's metadata.
  likes             Pull the list of users who liked a post
  comments          Pull the list of oldest comments on a post
  groupposts        Pull posts from a groups's timeline
  grouptags         Pull trending group tags.
  grouptrends       Pull trending groups.
  groupsuggestions  Pull list of suggested groups.

Search for users, statuses, groups, or hashtags

truthbrush search --searchtype [accounts|statuses|hashtags|groups] QUERY

Pull all statuses (posts) from a user

truthbrush statuses HANDLE

Pull "People to Follow" (suggested) users

truthbrush suggestions

Pull trendy tags

truthbrush tags

Pull ads

truthbrush ads

Pull all of a user's metadata

truthbrush user HANDLE

Pull the list of users who liked a post

truthbrush likes POST --includeall TOP_NUM

Pull the list of oldest comments on a post

truthbrush comments POST --includeall --onlyfirst TOP_NUM

Pull trending group tags

truthbrush grouptags

Pull trending groups

truthbrush grouptrends

Pull list of suggested groups

truthbrush groupsuggestions

Pull posts from a group's timeline

truthbrush groupposts GROUP_ID

Contributing

Contributions 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 truthbrush

To run the tests:

pytest

# optionally run tests with verbose logging outputs:
pytest --log-cli-level=DEBUG -s

Please format and lint your code with ruff, and run ty to check types:

ruff format .
ruff check .
ty check truthbrush/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

truthbrush-0.4.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

truthbrush-0.4.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file truthbrush-0.4.0.tar.gz.

File metadata

  • Download URL: truthbrush-0.4.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for truthbrush-0.4.0.tar.gz
Algorithm Hash digest
SHA256 850e207797dfff001413d5446a58f9bfa4367d84b73b701f5038c73d7fdf4494
MD5 aa80ef83b96c2f136e1fb49def774f76
BLAKE2b-256 526ff55daa16f18be5255afda48122165eae714fc09e0a6abef7937fa960eb32

See more details on using hashes here.

Provenance

The following attestation bundles were made for truthbrush-0.4.0.tar.gz:

Publisher: publish-to-pypi.yml on stanfordio/truthbrush

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file truthbrush-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: truthbrush-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for truthbrush-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d53de3a1fb9c209fe8477284852826b4b86a4d51b1042617b35bce8cbddbf2b6
MD5 3184aec0be1060c3359fa3f51da89a09
BLAKE2b-256 2abd66cfac668572081553a5595e192dbbc38923f195708b619cd6c45e20cf8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for truthbrush-0.4.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on stanfordio/truthbrush

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page