This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Dart package that provides a wrapper for the Splitwise API (v3.0). It's published on pub.dev and uses OAuth 1.0 for authentication. The package is null-safe (SDK >=2.12.0 <3.0.0) and uses the oauth1 package for authentication.
SplitWiseService (lib/src/util/auth/splitwise_main.dart): The main service class that handles all API interactions. It manages:
- OAuth 1.0 authentication flow using HMAC-SHA1 signature
- HTTP client initialization and lifecycle
- All API endpoint methods (users, groups, friends, expenses, comments, notifications, currencies)
TokensHelper (lib/src/util/helper/TokensHelper.dart): A simple data class for OAuth token management (token and tokenSecret). Provides serialization/deserialization methods for persistence.
Package Entry Point (lib/splitwise_api.dart): Exports the core classes using editor fold comments for organization.
The authentication uses a 3-step OAuth 1.0 flow:
- Call
validateClient()with no parameters to get authorization URL - User authorizes and receives verifier code
- Call
validateClient(verifier: code)to exchange for tokens (returns TokensHelper) - For subsequent sessions: call
validateClient(tokens: savedTokens)to restore session
The validateClient() method has three distinct behaviors based on input parameters, serving as the sole authentication method.
All API methods follow a consistent pattern:
- Internal helper methods:
_makeGetRequest()and_makePostRequest() - Base URL:
https://secure.splitwise.com/api/v3.0/ - Both methods check for initialized
_clientbefore making requests - Return response body on success (200) or status code on failure
- Methods are organized into sections using editor fold comments: User, Group, Friends, Expenses, Comments, Notifications, Currencies
# Generate code (for JSON serialization if needed)
dart run build_runner build
# Watch mode for continuous generation
dart run build_runner watchNo test suite is currently present in the repository.
# Get dependencies
dart pub get
# Publish (requires proper credentials)
dart pub publish- No Data Models: The package deliberately does not include data model classes. API responses are returned as raw JSON strings or status codes. Users are expected to parse responses themselves.
- OAuth 1.0 Platform Configuration: Uses hardcoded Splitwise OAuth endpoints with HMAC-SHA1 signature method.
- Error Handling: Throws exceptions when
_clientis not initialized. Some methods return boolean (success) or errors object. - Editor Fold Comments: Code is organized using
<editor-fold desc="...">comments for IDE folding. - Token Persistence: Not handled by the package - developers must implement their own storage (SharedPreferences, secure storage, etc.).
When adding new API endpoints:
- Add method in appropriate section (User/Group/Friends/Expenses/etc.)
- Use
_makeGetRequest()or_makePostRequest()with path and optional query parameters - Follow naming convention:
getResource(),createResource(),updateResource(),deleteResource() - For delete operations that return success flags, check
t.successand returntrueort.errors
Current version: 2.0.3
- Uses OAuth 1.0 (not OAuth 2.0)
- All methods from Splitwise DEV API website are included
- Based on null-safety