Okra

What will you build with Okra?

Find out what you can build with Okra’s API through our documentation, SDKs and sample use cases.

Quickstart Guides

Learn more about Okra and integrate with your web or mobile app through our libraries & SDKs.

Get Started
UI frame

API Documentation

The Okra documentation is your guide for all things development.

Read the documentation
UI frame

Okra Apps

A no-code option to integrate and customise Okra with your apps.

Link with Okra Widget
UI frame

Spending Patterns

Create a better experience with Spending Patterns

Calculate a Customer's Spending Patterns

Okra’s machine-learning models are constantly evolving to provide the best APIs for you. With Spending Patterns, you get insight into how users spend over time.

📘

Not a Developer?

You can turn on Spending Patterns by simply toggling a switch within the Add-on tab or the inner Transactions page of any of your customers.

You get a breakdown of expenses per category and real-time insights based on expenses after monthly income.

curl -X POST https://api.okra.ng/v2/products/spending-patterns/process
-H 'Content-Type: application/json' 
-H 'Authorization: Bearer <AccessToken>'
-d '{
        account: "5fe0a6f8ee69d878a679ef39",
            customer: "5fe0a6f8ee69d878a679ef39"
    }'
const okra_client = require("okra-node")
okra_client.getSpendingPattern(accessToken {customer_id: "insert customer ID" }, (err, results) => {
    // Handle err
    const spendingPattern = results.spending_pattern;
    });
{
    "status": "success",
    "data": {
        "data": {
            "channel": {
                "Cash": {
                    "count": 1,
                    "percentage": 0.1,
                    "sum": 2625
                },
                "Transfer": {
                    "count": 43,
                    "percentage": 0.16,
                    "sum": 4306.2
                },
                "web_pos": {
                    "count": 43,
                    "percentage": 99.55,
                    "sum": 2634313.15
                }
            },
            "confidence": 76.14,
            "debit_count": 88,
            "last_year_total": 27265.929999999993,
            "last_year_total_minus_tax": 27265.929999999993,
            "pattern": {
                "food": {
                    "count": 1,
                    "percentage": 0.57,
                    "sum": 15000
                },
                "miscellaneous": {
                    "count": 42,
                    "percentage": 11.48,
                    "sum": 303739.2
                },
                "taxes": {
                    "count": 2,
                    "percentage": 0.02,
                    "sum": 567
                },
                "transportation": {
                    "count": 2,
                    "percentage": 0.8,
                    "sum": 21092.5
                }
            },
            "streams": [
                {
                    "average_amount_spent": 180.01,
                    "average_frequency": 110,
                    "channel": "",
                    "count": 6,
                    "debit_text": "",
                    "pattern": "",
                    "period": null
                }
            ],
            "range": {
                "months": 22
            }
        },
        "status": "success",
        "msg": "Spending Patterns succesfully processed!",
        "receipt": {
            "status": true,
            "msg": "Receipt has been successfully created",
            "data": {
                "receipt": {
                    "breakdown": {
                        "discount": 0,
                        "billable_products": []
                    },
                    "billingStatus": true,
                    "method": "",
                    "charge": 62.25,
                    "addons": [],
                    "_id": "",
                    "owner": "",
                    "type": "",
                    "currency": "",
                    "plan": "",
                    "created_at": "",
                    "last_updated": "",
                    "__v": 0
                }
            }
        },
        "record": null
    }
}

Run in PostmanRun in Postman

Updated 2 months ago


What's Next

Check this article on how to implement complete view

Complete View

Spending Patterns


Create a better experience with Spending Patterns

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.