A Python wrapper for the Fluxer.web API, similar to discord.py
Project description
fluxerpy3
A Python wrapper for the Fluxer.web API, inspired by discord.py's design.
Features
- Async/await support - Built with modern Python async/await syntax
- Easy to use - Simple and intuitive API similar to discord.py
- Type hints - Full type hint support for better IDE integration
- Event system - Register event handlers for various actions
- Comprehensive models - User, Post, and Comment models with rich properties
- Error handling - Custom exceptions for different error scenarios
Installation
pip install fluxerpy3
Or install in development mode:
pip install -e .
Quick Start
import asyncio
import fluxerpy3
async def main():
# Create a client with your authentication token
client = fluxerpy3.Client(token="your_token_here")
async with client:
# Get current user
me = await client.get_me()
print(f"Logged in as: {me.username}")
# Get feed
posts = await client.get_feed(limit=10)
for post in posts:
print(f"{post.author.username}: {post.content}")
# Create a post
new_post = await client.create_post("Hello from fluxerpy3! 🚀")
print(f"Created post: {new_post.id}")
asyncio.run(main())
Usage Examples
User Operations
# Get a user by username
user = await client.get_user_by_username("example_user")
# Follow/unfollow a user
await user.follow()
await user.unfollow()
# Get user's posts
posts = await user.get_posts(limit=20)
Post Operations
# Create a post
post = await client.create_post("Hello world!")
# Like/unlike a post
await post.like()
await post.unlike()
# Repost a post
await post.repost()
# Delete a post
await post.delete()
# Get comments
comments = await post.get_comments()
Comment Operations
# Comment on a post
comment = await post.comment("Great post!")
# Like a comment
await comment.like()
# Delete a comment
await comment.delete()
Event Handling
client = fluxerpy3.Client(token="your_token_here")
@client.event
async def on_post_created(post):
print(f"New post created: {post.content}")
async def main():
async with client:
# Creating a post will trigger the event
await client.create_post("Test post")
asyncio.run(main())
API Reference
Client
The main client class for interacting with the Fluxer API.
Methods:
get_me()- Get the currently authenticated userget_user(user_id)- Get a user by IDget_user_by_username(username)- Get a user by usernamefollow_user(user_id)- Follow a userunfollow_user(user_id)- Unfollow a userget_feed(limit)- Get the user's feedget_post(post_id)- Get a post by IDcreate_post(content, media_urls)- Create a new postdelete_post(post_id)- Delete a postlike_post(post_id)- Like a postunlike_post(post_id)- Unlike a postrepost(post_id)- Repost a postget_post_comments(post_id, limit)- Get comments on a postcreate_comment(post_id, content)- Create a commentdelete_comment(comment_id)- Delete a commentlike_comment(comment_id)- Like a commentunlike_comment(comment_id)- Unlike a comment
Models
User
Represents a Fluxer user.
Properties:
id- User IDusername- Usernamedisplay_name- Display namebio- User bioavatar_url- Avatar URLfollower_count- Number of followersfollowing_count- Number of users being followedpost_count- Number of postscreated_at- Account creation date
Methods:
follow()- Follow this userunfollow()- Unfollow this userget_posts(limit)- Get posts by this user
Post
Represents a Fluxer post.
Properties:
id- Post IDcontent- Post contentauthor_id- Author's user IDauthor- Author user objectlike_count- Number of likescomment_count- Number of commentsrepost_count- Number of repostscreated_at- Post creation datemedia_urls- List of media URLs
Methods:
like()- Like this postunlike()- Unlike this postrepost()- Repost this postdelete()- Delete this postget_comments(limit)- Get commentscomment(content)- Add a comment
Comment
Represents a comment on a post.
Properties:
id- Comment IDcontent- Comment contentauthor_id- Author's user IDauthor- Author user objectpost_id- ID of the postlike_count- Number of likescreated_at- Comment creation date
Methods:
like()- Like this commentunlike()- Unlike this commentdelete()- Delete this comment
Error Handling
import fluxerpy3
from fluxerpy3 import AuthenticationError, NotFoundError, RateLimitError
try:
async with fluxerpy3.Client(token="invalid_token") as client:
await client.get_me()
except AuthenticationError:
print("Invalid authentication token")
except NotFoundError:
print("Resource not found")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
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 fluxerpy3-0.1.1.tar.gz.
File metadata
- Download URL: fluxerpy3-0.1.1.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e94f13a45c4f5618585a5f81348b64a5e185bbfbb1e672b35d64efff16d10e0e
|
|
| MD5 |
29a3b023b08f61bce6e3da7a74e76591
|
|
| BLAKE2b-256 |
e05b88bed086fd02acd9c500fc0247f2461a945c681dfc7bc47129896485876e
|
File details
Details for the file fluxerpy3-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fluxerpy3-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c68867504551b938597eebad44c76fa356103831e6c11bcc97d4a8306932fb0
|
|
| MD5 |
f1fb27b58f88cc8c3675cd1ccf2397f6
|
|
| BLAKE2b-256 |
c89efbdd6c9d13fd148ae56e849866887f4b3582c0b370882e419849c830be1a
|