11# Pagination
22
3- All list methods return a ` PaginatedResponse ` object for easy iteration through results.
3+ !!! note "API Behavior"
4+ The FinWise API does not currently support pagination for list endpoints. All ` list() ` methods return all available items as a simple Python list.
45
56## Basic Usage
67
@@ -9,67 +10,44 @@ from finwise import FinWise
910
1011client = FinWise(api_key = " your-api-key" )
1112
12- # Get first page
13- accounts = client.accounts.list(page_number = 1 , page_size = 50 )
13+ # Get all accounts
14+ accounts = client.accounts.list()
15+ print (f " Found { len (accounts)} accounts " )
1416
15- print (f " Page { accounts.page_number} of { accounts.total_pages} " )
16- print (f " Showing { len (accounts)} of { accounts.total_count} accounts " )
17- ```
18-
19- ## PaginatedResponse Properties
20-
21- | Property | Type | Description |
22- | ----------| ------| -------------|
23- | ` data ` | ` list ` | Items on the current page |
24- | ` page_number ` | ` int ` | Current page number (1-indexed) |
25- | ` page_size ` | ` int ` | Items per page |
26- | ` total_count ` | ` int ` | Total items across all pages |
27- | ` total_pages ` | ` int ` | Total number of pages |
28- | ` has_next ` | ` bool ` | Whether there's a next page |
29- | ` has_previous ` | ` bool ` | Whether there's a previous page |
30-
31- ## Iterating Through Items
32-
33- ``` python
34- # Iterate through items on this page
35- for account in accounts.data:
36- print (account.name)
37-
38- # Or iterate directly on the response
17+ # Iterate through items
3918for account in accounts:
4019 print (account.name)
4120
4221# Access by index
43- first_account = accounts[0 ] # or accounts.data[0]
22+ first_account = accounts[0 ]
4423```
4524
46- ## Fetching Multiple Pages
47-
48- ``` python
49- # Check for more pages
50- if accounts.has_next:
51- next_page = client.accounts.list(
52- page_number = accounts.page_number + 1 ,
53- page_size = 50 ,
54- )
55- ```
25+ ## List Methods
5626
57- ## Iterating Through All Pages
27+ All list methods return a ` list ` of model objects:
5828
59- ``` python
60- page_number = 1
61- all_accounts = []
29+ | Method | Return Type |
30+ | --------| -------------|
31+ | ` accounts.list() ` | ` list[Account] ` |
32+ | ` transactions.list() ` | ` list[Transaction] ` |
33+ | ` transaction_categories.list() ` | ` list[TransactionCategory] ` |
34+ | ` account_balances.list() ` | ` list[AccountBalance] ` |
6235
63- while True :
64- accounts = client.accounts.list(
65- page_number = page_number,
66- page_size = 100
67- )
68- all_accounts.extend(accounts.data)
36+ ## Filtering
6937
70- if not accounts.has_next:
71- break
72- page_number += 1
38+ While pagination is not supported, you can still filter results using available parameters:
7339
74- print (f " Fetched { len (all_accounts)} accounts " )
40+ ``` python
41+ # Filter transactions by date range
42+ transactions = client.transactions.list(
43+ start_date = date(2024 , 1 , 1 ),
44+ end_date = date(2024 , 1 , 31 ),
45+ type = " expense" ,
46+ )
47+
48+ # Filter by account
49+ transactions = client.transactions.list(account_id = " acc_123" )
50+
51+ # Filter account balances
52+ balances = client.account_balances.list(account_id = " acc_123" )
7553```
0 commit comments