Volver al ranking

snarfed/bridgy-fed

Pythonfed.brid.gy

🌉 A bridge between decentralized social networks

activitypubfediverseindiewebatprotobluesky
Crecimiento de estrellas
Estrellas
1.2k
Forks
57
Crecimiento semanal
Issues
211
5001k
ene 2023mar 2024may 2025jul 2026
ArtefactosPyPIpip install bridgy-fed
README

Bridgy Fed Circle CI Coverage Status

Bridgy Fed connects different decentralized social network protocols. It currently supports the fediverse (eg Mastodon) via ActivityPub, Bluesky via the AT Protocol, and the IndieWeb via webmentions and microformats2. Farcaster and Nostr are under consideration. Bridgy Fed translates profiles, likes, reposts, mentions, follows, and more from any supported network to any other. See the user docs and developer docs for more details.

https://fed.brid.gy/

License: This project is placed in the public domain. You may also use it under the CC0 License.

Development

Development reference docs are at bridgy-fed.readthedocs.io. Pull requests are welcome! Feel free to ping me in #indieweb-dev with any questions.

First, fork and clone this repo. Then, install the Google Cloud SDK and run gcloud components install cloud-firestore-emulator to install the Firestore emulator. Once you have them, set up your environment by running these commands in the repo root directory:

gcloud config set project bridgy-federated
python3 -m venv local
source local/bin/activate
pip install -r requirements.txt
# needed to serve static files locally
ln -sf local/lib/python3*/site-packages/oauth_dropins/static oauth_dropins_static

You can also use uv instead of pip, but if you do, pass it --no-sources.

Now, run the tests to check that everything is set up ok:

gcloud emulators firestore start --host-port=:8089 --database-mode=datastore-mode < /dev/null >& /dev/null &
python3 -m unittest discover

Finally, run this in the repo root directory to start the web app locally:

env FLASK_ENV=development APPVIEW_HOST=api.bsky.app PLC_HOST=plc.directory BGS_HOST=bsky.network PDS_HOST=atproto.brid.gy flask --debug run -p 8080

If you send a pull request, please include (or update) a test for the new functionality!

You may need to change granary, oauth-dropins, mf2util, or other dependencies as well as as Bridgy Fed. To do that, clone their repo locally, then install them in "source" mode with e.g.:

pip uninstall -y granary
pip install -e <path to granary>

To deploy to the production instance on App Engine - if @snarfed has added you as an owner - run:

gcloud -q beta app deploy --no-cache --project bridgy-federated *.yaml

How to add a new protocol

  1. Determine how you'll map the new protocol to other existing Bridgy Fed protocols, specifically identity, protocol inference, events, and operations. Add those to the existing tables in the docs in a PR. This is an important step before you start writing code.
  2. Add the new protocol to DEBUG_PROTOCOLS in models.py.
  3. Implement the id and handle conversions in ids.py.
  4. If the new protocol uses a new data format - which is likely - add that format to granary in a new file with functions that convert to/from ActivityStreams 1 and tests. See nostr.py and test_nostr.py for examples.
  5. Implement the protocol in a new .py file as a subclass of both Protocol and User. Implement send, fetch, serve, target_for, create_for, and other necessary methods from Protocol, and handle, handle_for_id, web_url, and other necessary methods from User .
  6. TODO: add a new usage section to the docs for the new protocol.
  7. TODO: does the new protocol need any new UI or signup functionality? Unusual, but not impossible. Add that if necessary.
  8. Protocol logos may be emoji and/or image files. If this one has a file, add it static/. Then add the emoji and/or file <img> tag to the Protocol subclass's LOGO_EMOJI and/or LOGO_HTML constants.

How to post as the protocol bot accounts: @ap.brid.gy, @bsky.brid.gy, etc

The protocol bot accounts - @ap.brid.gy, @bsky.brid.gy, and so on - don't have user-facing UIs to log into and post as, but it's still possible to post as them! And repost etc. Here's how.

They're currently set up as bridged web accounts. To post to them, first create a blog post without title on snarfed.org, check that it's under 300 chars for Bluesky, then send a webmention to Bridgy Fed to make it bridge the post. The source should be of the form eg https://[subdomain].brid.gy/internal/[URL], where URL is the snarfed.org post's URL, without https://, eg https://ap.brid.gy/internal/snarfed.org/2025-06-09_55084.

cd ~/src/bridgy-fed && curl -v -H "Authorization: `cat flask_secret_key`" \
  -d source=https://ap.brid.gy/internal/snarfed.org/... \
  -d force=true \
  https://fed.brid.gy/webmention

cd ~/src/bridgy-fed && curl -v -H "Authorization: `cat flask_secret_key`" \
  -d source=https://bsky.brid.gy/internal/snarfed.org/... \
  -d force=true \
  https://fed.brid.gy/webmention

(Ideally we'd like to be able to do this from blog.anew.social too! They don't support microformats in the default theme, though, so we'd need to switch to a microformats-enabled theme first. 😕)

GCP Artifact Registry cleanup policies

[artifact-registry-cleanup-policy.json](https://github.com/snarfed/bridgy-fed/blob/main/artifact-registry-cleanup-policy.json) is an Artifact Registry cleanup policy that automatically deletes old Docker images built by Cloud Build in our repos. Background.

Apply with:

gcloud artifacts repositories set-cleanup-policies gae-flexible \
    --location us-central1 \
    --policy=artifact-registry-cleanup-policy.json

gcloud artifacts repositories set-cleanup-policies gae-standard \
    --location us-central1 \
    --policy=artifact-registry-cleanup-policy.json

gcloud artifacts repositories set-cleanup-policies cloud-run-source-deploy \
    --location us-central1 \
    --policy=artifact-registry-cleanup-policy.json

Stats

I occasionally generate stats and graphs of usage and growth via BigQuery, like I do with Bridgy. Here's how.

  1. Export the full datastore to Google Cloud Storage. Include all entities except MagicKey. Check to see if any new kinds have been added since the last time this command was run.

    gcloud datastore export --async gs://bridgy-federated.appspot.com/stats/ --kinds Follower,Object
    

    Note that --kinds is required. From the export docs:

    Data exported without specifying an entity filter cannot be loaded into BigQuery.

  2. Wait for it to be done with gcloud datastore operations list | grep done.

  3. Import it into BigQuery:

    for kind in Follower Object; do
      bq load --replace --nosync --source_format=DATASTORE_BACKUP datastore.$kind gs://bridgy-federated.appspot.com/stats/all_namespaces/kind_$kind/all_namespaces_kind_$kind.export_metadata
    done
    
  4. Check the jobs with bq ls -j, then wait for them with bq wait.

  5. Run the full stats BigQuery query. Download the results as CSV.

  6. Open the stats spreadsheet. Import the CSV, replacing the data sheet.

  7. Check out the graphs! Save full size images with OS or browser screenshots, thumbnails with the Download Chart button.

Repositorios relacionados
mastodon/mastodon

Your self-hosted, globally interconnected microblogging community

RubyRubyGemsGNU Affero General Public License v3.0mastodondocker
joinmastodon.org
50.1k7.5k
Chocobozzz/PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser

TypeScriptnpmGNU Affero General Public License v3.0videodecentralized
joinpeertube.org
15.2k1.8k
LemmyNet/lemmy

🐀 A decentralised discussion platform for communities.

Rustcrates.ioGNU Affero General Public License v3.0link-aggregatorfediverse
join-lemmy.org
14.5k960
owncast/owncast

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

GoGo ModulesMIT Licensevideostreaming-video
owncast.online
11.4k1.2k
misskey-dev/misskey

🌎 A completely free and open interplanetary-microblogging platform 🚀

TypeScriptnpmGNU Affero General Public License v3.0misskeyactivitypub
misskey-hub.net
11.2k1.6k
pixelfed/pixelfed

Photo Sharing. For Everyone.

PHPPackagistGNU Affero General Public License v3.0laravelactivitypub
pixelfed.org
7k867
writefreely/writefreely

A clean, Markdown-based publishing platform made for writers. Write together and build a community.

GoGo ModulesGNU Affero General Public License v3.0writingpublishing
writefreely.org
5.2k384
superseriousbusiness/gotosocial

Fast, fun, small ActivityPub server.

GoGo ModulesGNU Affero General Public License v3.0mastodonfediverse
docs.gotosocial.org
4.1k365
bookwyrm-social/bookwyrm

Social reading and reviewing, decentralized with ActivityPub

PythonPyPIOtheractivitypubdecentralization
joinbookwyrm.com
2.7k324
Plume-org/Plume

Federated blogging application, thanks to ActivityPub (now on https://git.joinplu.me/ — this is just a mirror)

Rustcrates.ioGNU Affero General Public License v3.0activitypubblog
joinplu.me
2.2k145
aeharding/voyager

Voyager — a beautiful app for Lemmy and Piefed

TypeScriptnpmGNU Affero General Public License v3.0fediverselemmy
getvoyager.app
1.8k174
LemmyNet/jerboa

A native Android app for Lemmy

KotlinGNU Affero General Public License v3.0activitypubandroid
1.3k175