Visit the Accounts reference area for background details.

The account API client allows information about accounts to be retrieved, it also allows performing specific queries on specific accounts. Below are code samples that show how this client can be used.

Configure a new account API client

var config = new Configuration("{api-token}", Environment.Staging);
IAccountApiClient accountClient = new AccountApiClient(config);

Retrieve account balances

IEnumerable<AccountBalance> accountBalances = 
  await accountClient.GetAccountBalancesAsync();

Retrieve all accounts

IEnumerable<Account> accounts = await accountClient.GetAccountsAsync();

Retrieve account entries

The account api client allows you to get account entries by specific queries by creating a new AccountEntryQuery class, which has several overloads for different types of queries.

Note that the count parameter is optional, default count for all queries is 25.

// query all account entries with an option of count
var queryAllEntries = new AccountEntryQuery(100);
var queryEntriesWithCount = new AccountEntryQuery(100, 5);

// query by account id, max entry id and an option of count
var queryWithMaxId = new AccountEntryQuery(100, 5000L);
var queryWithMaxIdAndCount = new AccountEntryQuery(100, 5000L, 5);

// query by account id, start date, end date and an option of count
var queryByDateRange = 
  new AccountEntryQueryByDateRange(100, DateTime.Now, DateTime.Now.AddDays(-1));

var queryByDateRangeAndCount = 
  new AccountEntryQueryByDateRange(100, DateTime.Now, DateTime.Now.AddDays(-1), 5); 

// query by account id, start entry id, end entry id and an option of count
var queryByEntryRange = new AccountEntryQueryByEntryIdRange(100, 500000L, 600000L);
var queryByEntryRangeAndCount = new AccountEntryQueryByEntryIdRange(100, 500000L, 600000L, 5);

The query can then be used to get account entries.

IPage<AccountEntry, Uri> firstPage = 
  await accountClient.GetAccountEntriesAsync(query);

// get next page of account entries
IPage<AccountEntry, Uri> nextPage = await firstPage.GetNextPageAsync();

// get account entries of the current page
IEnumerable<AccountEntry> currentEntries = firstPage.CurrentItem;

// check if there are more account entries
bool moreResults = firstPage.HasMoreResults;

// get the token to use for getting the next page of account entries
Uri token = firstPage.NextPageToken;

The account API client also allows to use the next page token to get a specific page of account entry results.

// Retrieve account entries from Uri token
IPage<AccountEntry, Uri> page = 
  await accountClient.ContinueGetAccountEntriesAsync(token);