Skip to main content

farcaster-py

Note: This project is not actively maintained, but we welcome external contributions and forks. If you’d like to contribute, please open a PR or fork this repository.

Build status Python Version Dependencies Status Code style: black Security: bandit Pre-commit Semantic Versions License Coverage Report chat

farcaster-py is a modern Python SDK for the Farcaster protocol

Full documentation can be found here

Installation

pip install -U farcaster

or install with Poetry:

poetry add farcaster

Usage

This SDK leverages the Warpcast API. Warpcast is one of many Farcaster clients. As more APIs are created and hosted by different clients, these will be added to the SDK.

To use the Warpcast API you need to have a Farcaster account. We will use the mnemonic or private key of the Farcaster custody account (not your main wallet) to connect to the API.

First, save your Farcaster mnemonic or private key to a .env file. Now you can initialize the client, and automatically connect to the Farcaster API!

import os
from farcaster import Warpcast
from dotenv import load_dotenv # can be installed with `pip install python-dotenv`

load_dotenv()

client = Warpcast(mnemonic=os.environ.get("<MNEMONIC_ENV_VAR>"))

print(client.get_healthcheck())

Examples

Get a cast

response = client.get_cast("0x321712dc8eccc5d2be38e38c1ef0c8916c49949a80ffe20ec5752bb23ea4d86f")
print(response.cast.author.username) # "dwr"

Publish a cast

response = client.post_cast(text="Hello world!")
print(response.cast.hash) # "0x...."

Get a user by username

user = client.get_user_by_username("mason")
print(user.username) # "mason"

Get a user's followers using a fid (farcaster ID)

response = client.get_followers(fid=50)
print(response.users) # [user1, user2, user3]

Stream recent casts

for cast in client.stream_casts():
    if cast:
        print(cast.text) # "Hello world!"

Get users who recently joined Farcaster

response = client.get_recent_users()
print(response.users) # [user1, user2, user3]

Get your own user object

user = client.get_me()
print(user.username) # "you"

Recast a cast

response = client.recast("0x....")
print(response.cast.hash) # "0x...."

and many, many more things. The full specification can be found on the Reference page.

Please note that support for Python 3.8 is no longer actively maintained. Python 3.9, or 3.10+ are recommended.

🛡 License

License

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Disclaimer

This code is being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the code. It has not been audited and as such there can be no assurance it will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. Nothing in this repo should be construed as investment advice or legal advice for any particular facts or circumstances and is not meant to replace competent counsel. It is strongly advised for you to contact a reputable attorney in your jurisdiction for any questions or concerns with respect thereto. a16z is not liable for any use of the foregoing, and users should proceed with caution and use at their own risk. See our disclosures page for more info.

Metadata

Release files for farcaster 0.7.12

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

Source distribution (sdist)

Source distribution for farcaster 0.7.12
File Size Uploaded Provenance Actions
farcaster-0.7.12.tar.gz 16.5 kB Without provenance Details for farcaster-0.7.12.tar.gz

Built distribution (wheel)

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

Total release size: 31.8 kB

Release files / farcaster-0.7.12.tar.gz

Download URL farcaster-0.7.12.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0dba9be4439a2283d6c1a7c51560fb069170f007593f6efd2dfa2799dab07c05
BLAKE2b-256 checksum
How to use checksums
ce3ced98333598139be910030b26ba8bd40fad25a593beb4db2ab08af94a9465
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.9 Linux/6.8.0-1021-azure

Release files / farcaster-0.7.12-py3-none-any.whl

Download URL farcaster-0.7.12-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efb6e1f9bd113995a543baa548f92bb0e7d55b932eefa0f4522ca2454e5181ad
BLAKE2b-256 checksum
How to use checksums
f3085b7ec62b086fcb726f19b4f317ca856e2162f6f2b4f204431f99d368b9cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.9 Linux/6.8.0-1021-azure

Security for farcaster 0.7.12

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.

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