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
response = fcc.post_cast(text="Hello world!")
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]
Stream recent casts
for cast in fcc.stream_casts():
if cast:
print(cast.text) # "Hello world!"
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.
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.
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
Hashes for farcaster-0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f637f768e2b7c326e2865b8129d779551156c184d59f5775f7442268a252edbb |
|
MD5 | bbaf8ebde87e515dc8ca220b9391c7e5 |
|
BLAKE2b-256 | ee90ae30d7c0086e5a4c8ef6f2b01cdf33f5812483729b1b35d7f3de0ee9f889 |