A Python client for the Spliit API (group expense sharing)
Project description
Spliit Client
Spliit Client is a professional, well-documented Python client for the Spliit API, enabling seamless group expense sharing and management. This package is released under the permissive MIT License, making it suitable for both personal and commercial projects.
Note: This project is a fix and improvement on the work done in makp0/spliit-api-client, with enhanced structure, documentation, testing, and packaging.
Features
- Effortlessly create and manage expense groups
- Add and manage participants
- Add, retrieve, and delete expenses
- Multiple split modes: evenly, by shares, by percentage, by amount
- Comprehensive, categorized expense types
- Command-line interface (CLI) for quick operations
- Type hints and robust error handling
- Professional documentation and examples
Installation
From PyPI (Recommended)
pip install spliit_client
From Source
git clone https://github.com/abg0148/spliit_client.git
cd spliit_client
pip install -e .
Development Installation
git clone https://github.com/abg0148/spliit_client.git
cd spliit_client
pip install -e ".[dev]"
Quick Start
Basic Usage
from spliit_client import Spliit, SplitMode
# Create a new group
group = Spliit.create_group(
name="Trip to Paris",
currency="$",
participants=[
{"name": "Alice"},
{"name": "Bob"},
{"name": "Charlie"}
]
)
# Get participant IDs
participants = group.get_participants()
alice_id = participants["Alice"]
# Add an expense
expense_id = group.add_expense(
title="Dinner",
amount=6000, # Amount in cents ($60.00)
paid_by=alice_id,
paid_for=[
(alice_id, 1),
(participants["Bob"], 1),
(participants["Charlie"], 1)
],
split_mode=SplitMode.EVENLY,
notes="Dinner at a restaurant",
category=8 # Dining Out
)
# Retrieve all expenses
expenses = group.get_expenses()
for expense in expenses:
print(f"{expense['title']}: ${expense['amount']/100:.2f}")
Command-Line Interface (CLI)
Spliit Client provides a CLI for common operations:
# Create a new group
spliit create-group "Trip to Paris" --currency "$" --participants Alice Bob Charlie
# List all available categories
spliit list-categories
# Show version
spliit version
API Reference
Spliit Class
Class Methods
create_group(name, currency="$", server_url=OFFICIAL_INSTANCE, participants=None)- Create a new group and return a client instance.
Instance Methods
get_group()— Get group detailsget_participants()— Get all participants with their IDsget_username_id(name)— Get participant ID by nameget_expenses()— Get all expenses in the groupget_expense(expense_id)— Get details of a specific expenseadd_expense(...)— Add a new expense to the groupremove_expense(expense_id)— Remove an expense from the group
SplitMode Enum
SplitMode.EVENLY: Split the expense evenly among participantsSplitMode.BY_SHARES: Split by number of shares per participantSplitMode.BY_PERCENTAGE: Split by percentageSplitMode.BY_AMOUNT: Split by specific amounts
CATEGORIES Dictionary
A comprehensive dictionary of categorized expense types. See the code for details.
Example: Trip Expense Management
from spliit_client import Spliit, SplitMode
group = Spliit.create_group(
name="Weekend Trip to Mountains",
currency="$",
participants=[
{"name": "Alice"},
{"name": "Bob"},
{"name": "Charlie"},
{"name": "Diana"}
]
)
participants = group.get_participants()
alice_id = participants["Alice"]
bob_id = participants["Bob"]
charlie_id = participants["Charlie"]
diana_id = participants["Diana"]
# Add expenses
group.add_expense(
title="Gas for the trip",
amount=8000, # $80.00
paid_by=alice_id,
paid_for=[(alice_id, 1), (bob_id, 1), (charlie_id, 1), (diana_id, 1)],
split_mode=SplitMode.EVENLY,
category=31 # Gas/Fuel
)
group.add_expense(
title="Hotel room",
amount=20000, # $200.00
paid_by=bob_id,
paid_for=[(alice_id, 1), (bob_id, 1), (charlie_id, 1), (diana_id, 1)],
split_mode=SplitMode.EVENLY,
category=32 # Hotel
)
# Get all expenses
all_expenses = group.get_expenses()
print(f"Total expenses: {len(all_expenses)}")
for expense in all_expenses:
print(f"- {expense['title']}: ${expense['amount']/100:.2f}")
Development & Contribution
Setting Up
git clone https://github.com/abg0148/spliit_client.git
cd spliit_client
pip install -e ".[dev]"
Running Tests
pytest
pytest --cov=spliit_client
Code Quality
black spliit_client tests
flake8 spliit_client tests
mypy spliit_client
Building and Publishing
python -m build
# Test upload
python -m twine upload --repository testpypi dist/*
# Production upload
python -m twine upload dist/*
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add your feature') - Push to your branch (
git push origin feature/your-feature) - Open a Pull Request
License
This project is licensed under the MIT License. You are free to use, modify, and distribute this software for any purpose, including commercial applications, as long as the original copyright and license notice appear in all copies.
Acknowledgments
- Spliit for the expense sharing platform
- makp0/spliit-api-client for the original implementation
- The Python community for excellent tools and libraries
Support
If you encounter any issues or have questions:
- Check the documentation
- Search existing issues
- Create a new issue
Note: This is an unofficial client for the Spliit API. It is not affiliated with or endorsed by Spliit.
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 spliit_client-0.1.0.tar.gz.
File metadata
- Download URL: spliit_client-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2c06a355f783d68c82f14513fbda63603dd77b8f5f9ca64d7b62d8b5bfdb6e
|
|
| MD5 |
8c1737b6e78cae60ce3870c4242bd615
|
|
| BLAKE2b-256 |
fd4620ab7cb2c5050e4ea3b2dc98343675fdfc91b30eb04dbb02938f39bfc1d0
|
File details
Details for the file spliit_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spliit_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
181d3e92c51813a6d63d5d86b429cae2b6de7894c1e0afa8b896d7e50e65a696
|
|
| MD5 |
e89b87099bab5015d89472d5e2210d48
|
|
| BLAKE2b-256 |
ed2ceafa3e8bce51347862d553e3de80b698fb24e805eea81f2ad4de40288067
|