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 permissions on a broker connection, you can retrieve accounts, orders, and positions with a consistent API shape.

Overview

The most common read methods are:

  • getAccounts()
  • getOrders()
  • getPositions()

Each returns a standard response object. On success, result.success.data contains a PaginatedData collection that you can use like an array.

Get Accounts

Retrieve accounts across connected brokers:

1const result = await finatic.getAccounts(); 2 3if (result.success) { 4 const accounts = result.success.data; 5 console.log(`Found ${accounts.length} account(s)`); 6} else { 7 console.error('Failed to get accounts:', result.error); 8}
Account Filters

You can filter accounts with:

  • brokerId (string, optional): Filter by broker (e.g., 'alpaca', 'tastytrade')
  • connectionId (string, optional): Filter by connection ID
  • accountType (string, optional): Filter by account type (broker-specific enum)
  • status (string, optional): Filter by account status (broker-specific enum)
  • currency (string, optional): Filter by currency code (e.g., 'USD')
  • limit (number, optional): Number of results to return
  • offset (number, optional): Number of results to skip
  • includeMetadata (boolean, optional): Include additional metadata
1const result = await finatic.getAccounts({ 2 brokerId: 'alpaca', 3 accountType: 'margin', 4 currency: 'USD' 5});

Get Orders

Retrieve orders from connected brokers:

1const result = await finatic.getOrders(); 2 3if (result.success) { 4 const orders = result.success.data; 5 console.log(`Found ${orders.length} order(s)`); 6} else { 7 console.error('Failed to get orders:', result.error); 8}
Order Filters

You can filter orders with:

  • brokerId (string, optional): Filter by broker ID
  • connectionId (string, optional): Filter by connection ID
  • accountId (string, optional): Filter by account ID
  • symbol (string, optional): Filter by symbol (e.g., 'AAPL', 'TSLA')
  • orderStatus (enum, optional): Filter by status (broker-specific enum)
  • side (enum, optional): Filter by side ('buy', 'sell')
  • assetType (enum, optional): Filter by asset type ('equity', 'option', 'future', etc.)
  • createdAfter (string, optional): ISO 8601 lower bound
  • createdBefore (string, optional): ISO 8601 upper bound
  • limit (number, optional): Number of results to return
  • offset (number, optional): Number of results to skip
  • includeMetadata (boolean, optional): Include additional metadata
1const result = await finatic.getOrders({ 2 accountId: '123456789', 3 symbol: 'AAPL', 4 orderStatus: 'filled', 5 limit: 50 6});

Get Positions

Retrieve positions from connected brokers:

1const result = await finatic.getPositions(); 2 3if (result.success) { 4 const positions = result.success.data; 5 console.log(`Found ${positions.length} position(s)`); 6} else { 7 console.error('Failed to get positions:', result.error); 8}
Position Filters

You can filter positions with:

  • brokerId (string, optional): Filter by broker ID
  • connectionId (string, optional): Filter by connection ID
  • accountId (string, optional): Filter by account ID
  • symbol (string, optional): Filter by symbol (e.g., 'AAPL')
  • side (enum, optional): Filter by side ('long', 'short')
  • assetType (enum, optional): Filter by asset type
  • positionStatus (enum, optional): Filter by position status (broker-specific enum)
  • updatedAfter (string, optional): ISO 8601 lower bound
  • updatedBefore (string, optional): ISO 8601 upper bound
  • limit (number, optional): Number of results to return
  • offset (number, optional): Number of results to skip
  • includeMetadata (boolean, optional): Include additional metadata
1const result = await finatic.getPositions({ 2 accountId: '123456789', 3 symbol: 'AAPL', 4 side: 'long' 5});

Pagination

getAccounts(), getOrders(), and getPositions() return paginated data. On success:

  • result.success.data: PaginatedData collection (array-like)
  • result.success.data.hasMore: Whether additional pages exist
  • result.success.data.nextPage(): Fetch the next page
  • result.success.data.prevPage(): Fetch the previous page
  • result.success.data.firstPage(): Jump to the first page
  • result.success.data.lastPage(): Jump to the last page
1const result = await finatic.getOrders({ limit: 50 }); 2 3if (result.success) { 4 const page1 = result.success.data; 5 console.log(`Page 1: ${page1.length} order(s)`); 6 7 if (page1.hasMore) { 8 const page2 = await page1.nextPage(); 9 console.log(`Page 2: ${page2.length} order(s)`); 10 11 const page1Again = await page2.prevPage(); 12 console.log(`Back to page 1: ${page1Again.length} order(s)`); 13 } 14}

Manual pagination example

1const page1 = await finatic.getOrders({ limit: 50, offset: 0 }); 2const page2 = await finatic.getOrders({ limit: 50, offset: 50 });

Note: Each method also has a "get all" version (getAllAccounts(), getAllOrders(), getAllPositions()) that fetches all pages and returns a single array. Use those methods when you need the full dataset without manual pagination.


Response Format

All methods in this guide return the standard response object. Always check result.success or result.error before reading data:

1const result = await finatic.getAccounts(); 2 3if (result.success) { 4 const accounts = result.success.data; 5 // Process accounts 6} else if (result.error) { 7 console.error('Error:', result.error.message); 8 // Handle error 9} 10

For detailed response and error semantics, see:


Next Steps

Now that you've retrieved your data:

  1. Standard Response Object - Understand the response format used by all methods.
  2. Connecting Brokers - Learn how to connect brokerages to access real data.
  3. Error Handling - Review error handling patterns for robust applications.
  4. Explore the API Reference - See all available methods in the API Reference.
  5. Try the Interactive Playground - Test the SDK in your browser with our Interactive Playground.