farcaster-py is a Python SDK for the Farcaster Protocol
Project description
farcaster-py
Installation
pip install -U farcaster
or install with Poetry:
poetry add farcaster
Usage
To use the Farcaster 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 install dotenv:
pip install python-dotenv # Or 'poetry add python-dotenv'
Next, 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 MerkleApiClient
from dotenv import load_dotenv
load_dotenv()
client = MerkleApiClient(mnemonic=os.environ.get("<MNEMONIC_ENV_VAR>"))
print(client.get_healthcheck())
Examples
Get a cast
response = fcc.get_cast("0x321712dc8eccc5d2be38e38c1ef0c8916c49949a80ffe20ec5752bb23ea4d86f")
print(response.cast.author.username) # "dwr"
Publish a cast
from farcaster.models import CastsPostRequest
cast_body = CastsPostRequest(text="Hello world!")
response = fcc.post_cast(cast_body)
print(response.cast.hash) # "0x...."
Get a user by username
response = fcc.get_user_by_username("mason")
print(response.user.username) # "mason"
Get a user's followers using a fid (farcaster ID)
response = fcc.get_followers(fid=50)
print(response.users) # [user1, user2, user3]
Get users who recently joined Farcaster
response = fcc.get_recent_users()
print(response.users) # [user1, user2, user3]
Get your own user object
response = fcc.get_me()
print(response.user.username) # "you"
Recast a cast
response = fcc.recast("0x....")
print(response.cast.hash) # "0x...."
and many, many more things. The full specification can be found on the Reference page.
🛡 License
This project is licensed under the terms of the MIT license. See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file farcaster-0.5.0.tar.gz.
File metadata
- Download URL: farcaster-0.5.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1031-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a790c45cc04982b885ec607811599ad1f8e26172fb4b900c0a81dc22cafb1a9f
|
|
| MD5 |
1274b26dd1b7db6bebcb3e84eb96a0d3
|
|
| BLAKE2b-256 |
bd217bcb63cf88fc69113347e2f415e246d3b34d036befd64af7e077e71a4a18
|
File details
Details for the file farcaster-0.5.0-py3-none-any.whl.
File metadata
- Download URL: farcaster-0.5.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1031-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49f690e6efa047be0a61c10a71a283d532c35634b56fa5c9d4d949aab25efafa
|
|
| MD5 |
5c2aaece83e7297889e63e661e37f560
|
|
| BLAKE2b-256 |
b7752db1801a4705a7e83dd4c1851292abd053236355799c5c728dd4f7f2a3d0
|