{"library":"plaid","title":"Plaid Node.js Client","description":"The `plaid` package is the official Node.js client library for interacting with the Plaid API, providing programmatic access to financial data. Currently at version 42.1.0, the library is actively maintained with updates typically released on a monthly basis, aligning with Plaid API developments. It is generated directly from Plaid's OpenAPI schema, ensuring comprehensive coverage of the latest API version (specifically `2020-09-14`). A key differentiator is its direct support for various Plaid environments (sandbox, development, production) and its use of semantic versioning, with major version increments indicating potentially breaking changes. This client simplifies authentication and API request handling, abstracting the underlying HTTP requests and providing TypeScript type definitions for robust development.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install plaid"],"cli":null},"imports":["import { Configuration } from 'plaid';","import { PlaidApi } from 'plaid';","import { PlaidEnvironments } from 'plaid';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Configuration, PlaidApi, PlaidEnvironments, Products, CountryCode } from 'plaid';\n\n// Replace with your actual Plaid API credentials. Consider using environment variables.\nconst CLIENT_ID = process.env.PLAID_CLIENT_ID ?? 'your_client_id';\nconst SECRET = process.env.PLAID_SECRET ?? 'your_secret';\n\n// Configure the Plaid client\nconst configuration = new Configuration({\n  basePath: PlaidEnvironments.sandbox, // Or PlaidEnvironments.production for live data\n  baseOptions: {\n    headers: {\n      'PLAID-CLIENT-ID': CLIENT_ID,\n      'PLAID-SECRET': SECRET,\n      'Plaid-Version': '2020-09-14', // Recommended to explicitly set the API version\n    },\n  },\n});\n\nconst plaidClient = new PlaidApi(configuration);\n\nasync function getPlaidInstitutions() {\n  try {\n    // Define a request to fetch some institutions\n    const request = {\n      country_codes: [CountryCode.Us],\n      products: [Products.Auth],\n      count: 5,\n      offset: 0,\n    };\n    const response = await plaidClient.institutionsGet(request);\n    console.log('Successfully fetched top 5 Institutions:');\n    response.data.institutions.forEach(inst => console.log(`- ${inst.name} (ID: ${inst.institution_id})`));\n    return response.data.institutions;\n  } catch (error: any) {\n    if (error.response) {\n      // Log only necessary parts to avoid exposing secrets in error.response.config.headers\n      console.error('Plaid API Error:', error.response.data);\n    } else {\n      console.error('Plaid Client Error:', error.message);\n    }\n    throw error;\n  }\n}\n\n// Run the example\nPlaidEnvironments.sandbox === configuration.basePath ?\n  getPlaidInstitutions().then(() => console.log('\\nExample complete using Sandbox environment.')) :\n  console.warn('Warning: Not running institution fetch in non-sandbox environment for quickstart.');\n","lang":"typescript","description":"This quickstart demonstrates how to initialize the Plaid client with API credentials and environment, then fetch a list of top institutions using the `institutionsGet` endpoint. It includes basic error handling and best practices for environment variables and API versioning.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}