Fetch Account and Transaction Data with Connect
This guide is for Platform API v2011101. For guidance on the newest version, see Connectivity Integration Guides.
This guide assumes you are following MX's recommendation to use the Connect Widget. If your use case requires you to use API endpoints only, see our separate guide on this type of integration.
Prerequisites
Before you follow the steps in this guide make sure that you have:
- Signed up for the Platform API and received your development API Keys.
- Integrated the Connect Widget into your application or website. The best way to do this is to use one of the widget SDKs mentioned in Integration Guides that MX has created for this purpose.
Create a User
A user represents your end user in the MX Platform. Make a request to the Create User endpoint (POST /users).
We recommend that you include a unique id of your choice with the request. You may also include metadata, such as the date the user was created or the end user's name. Don't include any sensitive information here, such as credentials.
None of these parameters are required, but the user object can't be empty. We recommend that you always set the id parameter when creating a user.
In the response, the API gives each new user an MX-defined guid (or user_guid when appearing outside the user object). Between your id and the guid, you can map between your system and ours. You'll need the user guid for nearly every request on the MX API, at least when using basic authorization.
Request a Connect Widget URL
There are many configuration options for the Connect Widget for performing various tasks. Default configuration values are set with account aggregation in mind, so little configuration is required for simple aggregation. Nevertheless, you should carefully read the documentation on configuration options as they may be important for your particular use case.
Make a POST request to the /users/{user_guid}/widget_urls endpoint.
- In the body, set the
widget_typeparameter toconnect_widget. - In the path, set the
user_guidto the value for the user you created in step 1.
The response will contain a URL to Connect Widget which you will load in the next step.
Load the URL and Let the End User Interact
If you're following this guide for testing purposes, you must search for the test institution in the widget and enter the credentials mentioned in one of our testing guides.
Load the URL in your application or website. At this point the end user will interact with the Connect Widget. The widget handles the creation of a member as well as the aggregation process and any MFA that may be encountered. It automatically asks end users to search for an institution, give their credentials, or authenticate with OAuth. It also deals with any errors along the way.
You'll need to listen for a couple important event messages from the Connect Widget:
- member status updated which gives you the member GUID and the current
connection_status. - member connected tells you that the member has been successfully connected and you can move on to the next steps.
Alternatively, if the end user closes the Connect Widget early or some other problem occurs before you see a CONNECTED status, you can use the member_guid to immediately check the member's connection status with a dedicated API endpoint.
List Account Data
The aggregation process was successful and you can now read account information.
Make a GET request to the /users/{user_guid}/members/{member_guid}/accounts endpoint. The response will include all the accounts belonging to the member.
There is another endpoint for listing accounts which may be more suitable for your use case: GET /users/{user_guid}/accounts.
You may also consider reading the attributes of a specific account. There are two endpoints for this which return the same information, provided for code convenience:
GET /users/{user_guid}/members/{member_guid}/accounts/{account_guid}
GET /users/{user_guid}/accounts/{account_guid}
List Transaction Data
You can now read all the transaction data that has been gathered. Keep in mind that all list endpoints in the Platform API are paginated. To get the full list of transactions, you'll need to pay attention to the pagination object and make multiple requests specifying the page and the records_per_page in order to see all the available data. You can also limit results to a specific time frame using from_date and to_date.
There are multiple endpoints for listing transactions provided for code convenience. The others are:
GET /users/{user_guid}/accounts/{account_guid}/transactions
GET /users/{user_guid}/transactions
You may also wish to read the details of a specific account:
GET /users/{user_guid}/transactions/{transaction_guid}