Getting Data
Learn how to retrieve accounts, orders, positions, and other data from connected brokerages.
Once the session is initialized and the user has approved read permission on a broker connection, you can retrieve account data. Here are the most common methods:
Get Accounts
Retrieve all accounts from connected brokerages:
1const result = await finatic.getAccounts();
2
3if (result.success) {
4 const accounts = result.success.data; // PaginatedData - use directly as array
5 console.log(`Found ${accounts.length} account(s)`);
6} else {
7 console.error('Failed to get accounts:', result.error);
8}Get Orders
Retrieve orders from connected brokerages:
1const result = await finatic.getOrders();
2
3if (result.success) {
4 const orders = result.success.data; // PaginatedData - use directly as array
5 console.log(`Found ${orders.length} order(s)`);
6} else {
7 console.error('Failed to get orders:', result.error);
8}Get Positions
Retrieve positions from connected brokerages:
1const result = await finatic.getPositions();
2
3if (result.success) {
4 const positions = result.success.data; // PaginatedData - use directly as array
5 console.log(`Found ${positions.length} position(s)`);
6} else {
7 console.error('Failed to get positions:', result.error);
8}Pagination
The regular methods (getAccounts(), getOrders(), getPositions()) support pagination. The response data is a PaginatedData object that behaves like an array and includes navigation methods:
result.success.data: The paginated data (use directly as an array -result.success.data[0],result.success.data.length, etc.)result.success.data.hasMore: Boolean indicating if there are more pages availableresult.success.data.nextPage(): Fetches and returns the next page (e.g., if currently on page 1 with 50 results, this fetches results 51-100)result.success.data.prevPage(): Fetches and returns the previous page (e.g., if currently on page 2, this fetches the previous 50 results)result.success.data.firstPage(): Fetches and returns the first page of resultsresult.success.data.lastPage(): Fetches and returns the last page of results
You can also use limit and offset parameters to control pagination manually.
Example with pagination navigation methods:
1// Get first page (results 1-50)
2const result = await finatic.getOrders({ limit: 50 });
3
4if (result.success) {
5 const firstPage = result.success.data; // PaginatedData - use as array
6 console.log(`First page: ${firstPage.length} orders`);
7
8 // Check if there are more pages
9 if (firstPage.hasMore) {
10 // Get next page (results 51-100)
11 const secondPage = await firstPage.nextPage();
12 console.log(`Next page: ${secondPage.length} orders`); // Go back to previous page (results 1-50) const prevPage = await secondPage.prevPage(); console.log(`Previous page: ${prevPage.length} orders`); // Jump to last page const lastPage = await firstPage.lastPage(); console.log(`Last page: ${lastPage.length} orders`); // Jump back to first page const firstPageAgain = await lastPage.firstPage(); console.log(`First page: ${firstPageAgain.length} orders`); } }
13 const secondPage = nextResult.success.data;
14 console.log(`Next page: ${secondPage.length} orders`);
15
16 // Go back to previous page (results 1-50)
17 const prevResult = await nextResult.prevPage();
18 if (prevResult.success) {
19 console.log(`Previous page: ${prevResult.success.data.length} orders`);
20 }
21
22 // Jump to last page
23 const lastResult = await nextResult.lastPage();
24 if (lastResult.success) {
25 console.log(`Last page: ${lastResult.success.data.length} orders`);
26 }
27
28 // Jump back to first page
29 const firstResult = await lastResult.firstPage();
30 if (firstResult.success) {
31 console.log(`First page: ${firstResult.success.data.length}orders`);
32 }
33 }
34 }
35}Example with manual pagination:
1// Get first page (50 results)
2const page1 = await finatic.getOrders({ limit: 50, offset: 0 });
3
4// Get second page (next 50 results)
5const page2 = await finatic.getOrders({ limit: 50, offset: 50 });Note: Each method also has a "get all" version (
getAllAccounts(),getAllOrders(),getAllPositions()) that automatically handles pagination for you by fetching all pages and returning a single array with all results. Use these methods when you need all data without managing pagination manually.
Understanding the Response Format
All Finatic API methods return a consistent response format:
1{
2 success: {
3 data: { /* your data */ },
4 meta?: { /* optional metadata */ }
5 },
6 error: null,
7 warning: null
8}
9In case of an error:
1{
2 success: null,
3 error: {
4 message: "Error description",
5 code?: "ERROR_CODE",
6 status?: 400
7 },
8 warning: null
9}
10Next Steps
Now that you've retrieved your data:
- Connect Brokers - Learn how to connect brokerages to access real data
- Handle Errors - Review error handling patterns for robust applications
- Explore the API Reference - See all available methods in the API Reference
- Try the Interactive Playground - Test the SDK in your browser with our Interactive Playground
