Skip to main content

📢 MultiToeter

Introduction

MultiToeter is a python library providing a simplified unified API for sending messages to both the Twitter and Mastodon platform at the same time.

Usage

# install through pip
pip install multitoeter

Initialize through autoinit

MultiToeter support initializing your keys and secrets, needed for connecting to the Twitter and Mastodon API, through environment variables or through a .env file. Below are two examples on how to use this. You can mix and match these two methods. The priority is currently to try environment variables first followed by the .env file.

# Simple script to send a message through MultiToeter
# Save as: test.py
from multitoeter import autoinit_multitoeter

mt = autoinit_multitoeter()

toeter = mt.toeter('Testing MultiToeter API autoinit')
toeter = mt.toeter('Reply message', in_reply_to=toeter)
# environment variable example
# only use mastodon in this example
MASTODON_ACCESS_TOKEN=<..> MASTODON_BASE_URL=https://mstdn.science python test.py 
# .env file example
MASTODON_ACCESS_TOKEN=<..>
MASTODON_BASE_URL=https://mstdn.science

TWITTER_CONSUMER_KEY=<..>
TWITTER_CONSUMER_SECRET=<..>
TWITTER_ACCESS_TOKEN=<..>
TWITTER_ACCESS_TOKEN_SECRET=<..>

# Now run test.py:
# python test.py 

Initialize in code

A secondary approach is to initialize MultiToeter in code instead of using the autoinit. This gives you more flexibility and allows you to use more than one account for the same platform should you need it.

from multitoeter import Mastodon, Twitter, MultiToeter

mastodon1 = Mastodon(
  access_token="<..>",
  api_base_url="https://mstdn.science"
)
mastodon2 = Mastodon(
  access_token="<..>",
  api_base_url="https://mstdn.social/"
)

twitter1 = Twitter(
  consumer_key="<..>"
  consumer_secret="<..>"
  access_token="<..>"
  access_token_secret="<..>"
)

multi = MultiToeter({'mastodon1': mastodon1, 'mastodon2': mastodon2, 'twitter': twitter1})

toeter = multi.toeter("Test post via MultiToeter API")
toeter = multi.toeter("Test reply via MultiToeter API", in_reply_to=toeter)

Adding media files

Limited support for media files is available. The unified API expects you to point to the media files directly.

# Assume that the file test.jpg exists
from multitoeter import autoinit_multitoeter

mt = autoinit_multitoeter()

toeter = mt.toeter('Testing MultiToeter API autoinit', media_files=['test.jpg'])

Metadata

Release files for multitoeter 2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multitoeter 2
File Size Uploaded Provenance
multitoeter-2.tar.gz 4.3 kB Without provenance Details

Release files / multitoeter-2.tar.gz

Download URL multitoeter-2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
93677dc7ddfaaafccf524cc47f00da43c801a5dcdc7dc147ac3038abef935d68
BLAKE2b-256 checksum
How to use checksums
8a3647c27a75a7592c06ccdbbc1ba0f6807329c6adccdec960925a2031fc5bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for multitoeter 2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page