Skip to main content

Bovine

Bovine is a basic utility library for the Fediverse. It can be used both to build ActivityPub Client applications and ActivityPub Servers. In addition to ActivityPub support, it also provides utilities to deal with webfinger, nodeinfo, and HTTP Signatures.

The bovine library can just be installed via pip

pip install bovine

Documentation including tutorials is available at ReadTheDocs.

A quick Fediverse server with docker compose

Using the bovine docker image, the following docker compose file, and a service such as ngrok allowing one to expose a local port to the internet, one can create a python shell that allows one to use bovine to interact with the Fediverse

services:
  bovine:
    image: helgekr/bovine
    environment:
    - "BOVINE_TEST_HOSTNAME=${NGROK_HOSTNAME}"
    - "BOVINE_TEST_PROTOCOL=https"
    volumes: ["bovine_shared:/bovine"]
    ports: ["5000:80"]
    command: python -mbovine.testing serve --port 80 --reload --save_config=/bovine/config.toml
  repl:
    image: helgekr/bovine
    command: python -mbovine.testing shell --load_config=/bovine/config.toml
    depends_on: [bovine]
    profiles: ["repl"]
    volumes: ["bovine_shared:/bovine"]
volumes:
  bovine_shared:

When using ngrok with ngrok http 5000, you can directly run the above file via

NGROK_HOSTNAME=$(curl --silent http://127.0.0.1:4040/api/tunnels  | jq '.tunnels[0].public_url' | sed "s|https://||g" | sed 's|"||g') docker compose run repl

otherwise you will have to set the variable BOVINE_TEST_HOSTNAME to the appropriate host.

By using

>>> helge = await webfinger("acct:helge@mymath.rocks")
>>> inbox = (await actor.get(helge))["inbox"]
>>> helge
"https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0"

one can resolve an acct uri to the actor's uri and then record its inbox. Then one can create a message via

>>> mention = {"href": helge, "type": "Mention"}
>>> note = object_factory.note(to={helge}, content="Writing a README thus talking to myself", tag=[mention]).as_public().build()
>>> note
{
    "@context": "https://www.w3.org/ns/activitystreams",
    "type": "Note",
    "attributedTo": "https://8fc-2003-c1-c73c-a901-b426-f511-88e5-77e3.ngrok-free.app/buttercup",
    "to": ["https://mymath.rocks/endpoints/SYn3cl_N4HAPfPHgo2x37XunLEmhV9LnxCggcYwyec0", "https://www.w3.org/ns/activitystreams#Public"],
    "id": "https://8fc-2003-c1-c73c-a901-b426-f511-88e5-77e3.ngrok-free.app/HFL5hpzi",
    "published": "2024-11-24T12:30:54Z",
    "content": "Writing a README thus talking to myself",
}

By then running

>>> await actor.post(inbox, activity_factory.create(note).build())
<ClientResponse(https://mymath.rocks/endpoints/SYONtD8yAKPapRuifwDJ8P0OhcuB7ntjkHdxh_OkrWQ) [202 None]>

one can post the message. It should then appear in your Fedi client

Screenshot of the message from buttercup

One can view messages received in the inbox via

docker compose logs -f

Further information on the testing server can be found in Using bovine with the fediverse-pasture in the documentation.

Feedback

Issues about bovine should be filed as an issue.

Running BDD Tests

bovine uses the fediverse-features to provide BDD tests. These can be run by first downloading the feature files via

poetry run python -mfediverse_features

and then running behave

poetry run behave

Contributing

If you want to contribute, you can start by working on issues labeled Good first issue. The tech stack is currently based on asynchronous python, using the following components:

Metadata

Release files for bovine 0.5.19

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

Source distribution (sdist)

Source distribution for bovine 0.5.19
File Size Uploaded
bovine-0.5.19.tar.gz 412.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bovine 0.5.19
File Interpreter ABI Platform
bovine-0.5.19-py3-none-any.whl Python 3 none any Details

Total release size: 664.5 kB

Release files / bovine-0.5.19.tar.gz

Download URL bovine-0.5.19.tar.gz
Size 412.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8ba93c041f127309781f96585e0fd5ba9aaf235f60843aad008d860952e7ddad
BLAKE2b-256 checksum
How to use checksums
af7577aa8f9fb9f4c3d3ff55fd5f5126935813cccb9548d4cac26f76317b9692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/6.12.32+bpo-amd64

Release files / bovine-0.5.19-py3-none-any.whl

Download URL bovine-0.5.19-py3-none-any.whl
Size 252.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
648a885b9dc5cc3e8e1ef2a42195953e6c82de5aaec481ea7bbb30495cb2148b
BLAKE2b-256 checksum
How to use checksums
d2c1fc12e496563509414ccf3bc33c7fd116d57e324b34116a4123d8dc1d9448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/6.12.32+bpo-amd64

Release history Release notifications | RSS feed

This release

0.5.19 This release

2 release files

0.5.15

2 release files

0.5.14

2 release files

0.5.12

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

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