The Spending Patterns API is one of our freshly renewed financial APIs that uses machine learning to classify your users’ spending habits. In this article, we’ll learn a little more about the Spending Patterns API and how to get started.
How the Spending Pattern API works
Spending Patterns is a user-permission product. Your users can grant access to their transaction data, which the Okra API then retrieves and sends to the Natural Language Understanding system - that’s a core part of Okra’s machine learning models that determine your users spending patterns. The NLU analyses and groups transaction data into spending categories and payment methods.
Using the Spending Patterns API
Sign up to the Okra dashboard if you haven’t already. Once in, head over to the Developer tab and get your Sandbox API key. Our Sandbox environment allows developers to test their applications before they take their ideas to production.
Once you have your API keys, you can set up a simple Express app by adding in the Okra Node SDK.
The Spending Patterns API can be used in two ways. Use the
/process endpoint to analyse data for new users, and the
/get endpoints to retrieve data for users that you already processed. Under the get endpoints, you can get customer records based on ID, record ID, and date.
To test the app, launch Postman and type in
localhost://3000. Set the request to POST and send a JSON request with the
customer_id as customer ID. If you are set up on a new account, you can create a new customer on the dashboard.
After processing a customer’s spending patterns, the response contains the following fields:
- Summary - This provides an overview of the transactions that the API uses for calculating spending patterns - capturing the confidence score, cash flow, timeline in months, the inflow and outflow of cash, and the transactions recognised.
- Breakdown - This provides details about each spending category and payment method that the API processed. Each spending category is classified by type and the details of each item are broken down into how many times transactions within the category have been made, the percentage of the total expenditure, and the total sum spent.
- Spending Categories - Each spending category is classified by type and the details of each item are broken down into how many times transactions within the category have been made, the percentage of the total expenditure and the total sum spent.
- Payment Methods - The Spending Patterns API determines what payment methods were used in the user’s transaction history - USSD, mobile app, or an online purchase - with each category’s total spend and the percentage of overall spend.
For more details on the full response, check out our documentation.
In conclusion, integrating Okra’s Spending Patterns API is a simple and effective way to help you analyze your user’s spending habits. This API allows developers to gain valuable insights from spending patterns to make informed financial decisions.
Start building with Okra right away!
If you are passionate about open finance, you should visit our website to see other services that might appeal to you.