Splitwise Python SDK
raw JSON → 3.0.0 verified Fri May 01 auth: no python
Unofficial Python SDK for the Splitwise API. Version 3.0.0 includes fixes for updateExpense and getExpenses. Release cadence is irregular.
pip install splitwise Common errors
error ImportError: cannot import name 'splitwise' ↓
cause Using import splitwise instead of from splitwise import Splitwise.
fix
Use: from splitwise import Splitwise
error splitwise.SplitwiseException: Invalid consumer key or consumer secret ↓
cause Consumer key/secret are incorrect or swapped with API key.
fix
Ensure you are using the correct consumer key and secret from your Splitwise app settings.
error AttributeError: 'Splitwise' object has no attribute 'getExpenses' ↓
cause Using an older version (<3.0.0) where getExpenses was broken or not available.
fix
Upgrade to splitwise>=3.0.0: pip install --upgrade splitwise
Warnings
breaking In v2.0.0, OAuth2 support was added. The constructor signature changed: OAuth1 uses consumer_key/consumer_secret, OAuth2 also requires access_token. ↓
fix Update code to match new constructor signature. For OAuth1, use setAccessToken() after authorization.
breaking In v3.0.0, updateExpense() and getExpenses() were fixed. Behavior may have changed from v2.x. ↓
fix Review expense update and expense listing logic after upgrading.
gotcha The SDK does not support Splitwise OAuth2 token refresh automatically. If your access token expires, you must re-authorize. ↓
fix Implement token refresh logic yourself by catching authorization errors and re-authorizing.
Imports
- Splitwise wrong
import splitwisecorrectfrom splitwise import Splitwise - Expense
from splitwise.expense import Expense
Quickstart
from splitwise import Splitwise
splt = Splitwise(consumer_key='YOUR_KEY', consumer_secret='YOUR_SECRET')
# For OAuth2, use access token
# splt = Splitwise(consumer_key='YOUR_KEY', consumer_secret='YOUR_SECRET', access_token='ACCESS_TOKEN')
print(splt.getCurrentUser())