Getting Started with Spending Patterns 2.0

In this article, we’ll learn a little more about the Spending Patterns API and how to get started.

Getting Started with Spending Patterns 2.0

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.

The code samples shown are in JavaScript. For more language examples, kindly check our API references section on our docs

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.

How Spending Patterns 2.0 works

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.

Postman response for Spending Patterns 2.0

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.

Conclusion

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.

Resources

Start building with Okra right away!

Check out our documentation to learn more about all Okra products. Also, sign up for a free account to start building with the Okra today.

If you are passionate about open finance, you should visit our website to see other services that might appeal to you.

Contact sales or send an email to sales@okra.ng to get started!