Exploring Plaid Public API

Plaid offers a suite of APIs that enable applications to interact with their users' financial data. Plaid docs provide a comprehensive guide to their public API, which makes it easier for developers to connect with banking accounts, verify identity, and complete transactions.

Here are some examples of Plaid public API code snippets in JavaScript:

Initialize the Plaid client

To access the Plaid API, first, we need to create an instance of the Plaid client.

const Plaid = require('plaid');
const plaidClient = new Plaid.Client({
  clientID: 'PLAID_CLIENT_ID',
  secret: 'PLAID_SECRET',
  env: Plaid.environments.sandbox,
});

Link bank account using Plaid's Auth API

Using Plaid's Auth API, users can authenticate their bank credentials and connect their accounts.

plaidClient.getLinkToken({
  user: { client_user_id: 'CUSTOM_USER_ID' },
  client_name: 'CLIENT_NAME',
  products: ['auth'],
  country_codes: ['US'],
  language: 'en',
}).then(linkTokenResponse => {
  const linkToken = linkTokenResponse.link_token;
  // Handle the link token on the front-end.
}).catch(error => {
  // Handle the error.
});

Getting Account Information

Once authenticated, we can access user account information using the Accounts API.

plaidClient.getAccounts(AUTH_TOKEN).then(accountResponse => {
  const accounts = accountResponse.accounts;
  // Handle the accounts.
}).catch(error => {
  // Handle the error.
});

Transactions API

We can access all transactions details through the Transactions API.

plaidClient.getTransactions(AUTH_TOKEN, startDate, endDate, {
  // options for getting transactions
}).then(transactionResponse => {
  const transactions = transactionResponse.transactions;
  // Handle the transactions.
}).catch(error => {
  // Handle the error.
});

Conclusion

Plaid's API documentation provides a rich resource for developers to explore and build financial applications. In this article, we covered some examples in JavaScript, but Plaid supports several other programming languages. Explore Plaid's developer documentation and get started building your next financial application!

Related APIs