Introduction

Accounts hold your funds. The accounts API method allows you to list your accounts and view balances for each account. When you sign up for Onafriq, at least one account in your primary currency is created for your organization. You can request additional accounts if needed.

📘

The accounts api endpoint is:

https://api.mfsafrica.com/api/accounts

The Account object

FieldTypeDescription
idlong integerUnique object identifier
organizationlong integerThe ID of the organization that the account belongs to. (This is usually your organization ID)
balancefloatThe current account balance
currencystringThe account’s currency code. i.e KES, UGX
statusstringThe account’s status. One of: active or inactive
createdstringThe date that the account was created, in the UTC timezone. Format: “YYYY-MM-DDTHH:MM:SSZ”
authorlong integerThe ID of the user who created the account
modifiedstringThe date that the account was last modified, in the UTC timezone. Format: “YYYY-MM-DDTHH:MM:SSZ”
updated_bystringThe ID of the user who last updated the account
{
    "id": 1146,
    "organization":1,
    "balance": 200.0,
    "currency": "KES",
    "status": "active",
    "created": "2015-02-13T04:22:31Z",
    "author": 7,
    "modified": "2015-02-26T13:00:35Z",
    "updated_by": 1
}

Retrieving a Single Account

To retrieve a single account, provide the account id and an account object will be returned.

Parameter (*required field)TypeDescription
id*Integer
Ex. 12
The id of the account you want to retrieve

Sample Request

curl https://api.mfsafrica.com/api/accounts/12 -H "Authorization: Token ab594c14986612f6167a975e1c369e71edab6900"
package com.beyonic.samples;

import com.beyonic.exceptions.BeyonicException;
import com.beyonic.models.*;

Beyonic.API_KEY = "ab594c14986612f6167a975e1c369e71edab6900";

String response = null;

try{
    response = new Account().get(123);
    System.out.println(response);
}
catch (Exception e){
    e.printStackTrace();
}
<?php
require_once('./lib/Beyonic.php');
Beyonic::setApiKey("ab594c14986612f6167a975e1c369e71edab6900");

$account = Beyonic_Account::get(12);
?>
import beyonic
beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

account = beyonic.Account.get(12)
require 'beyonic'
Beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

account = Beyonic::Account.get(12)

Sample Response

📘

Note

Sample Response (JSON) - if you use one of the development libraries, this is automatically converted into a native object for you:

{
    "id": 12,
    "organization":1,
    "balance": 200.0,
    "currency": "KES",
    "status": "active",
    "created": "2015-02-13T04:22:31Z",
    "author": 7,
    "modified": "2015-02-26T13:00:35Z",
    "updated_by": 1
}
}

Listing all accounts

To retrieve a list of all accounts, make a GET request to the accounts end point. This will return a list of accounts.

Sample Request

curl https://api.mfsafrica.com/api/accounts -H "Authorization: Token ab594c14986612f6167a975e1c369e71edab6900"
package com.beyonic.samples;

import com.beyonic.exceptions.BeyonicException;
import com.beyonic.models.*;

Beyonic.API_KEY = "ab594c14986612f6167a975e1c369e71edab6900";

String response = null;

try{
    response = new Account().list(null, null);
    System.out.println(response);
}
catch (Exception e){
    e.printStackTrace();
}
<?php
require_once('./lib/Beyonic.php');
Beyonic::setApiKey("ab594c14986612f6167a975e1c369e71edab6900");

$accounts = Beyonic_Account::getAll();
?>
import beyonic
beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

accounts = beyonic.Account.list()
require 'beyonic'
Beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

accounts = Beyonic::Account.list

Sample Response

📘

Note

Sample Response (JSON) - if you use one of the development libraries, this is automatically converted into a native object for you:

{
    "count": 2,
    "next": "https://api.mfsafrica.com/api/accounts?offset=10",
    "previous": null,
    "results": [
        {
            "id": 1146,
            "organization":1,
            "balance": 200.0,
            "currency": "KES",
            "status": "active",
            "created": "2015-02-13T04:22:31Z",
            "author": 7,
            "modified": "2015-02-26T13:00:35Z",
            "updated_by": 1
        },
        {
            "id": 1147,
            "organization":1,
            "balance": 100.0,
            "currency": "UGX",
            "status": "active",
            "created": "2015-02-13T04:22:31Z",
            "author": 7,
            "modified": "2015-02-26T13:00:35Z",
            "updated_by": 1
        },
    ]
}

Filtering Accounts

You can search or filter accounts on the following fields. Simply add them to your request as shown in the examples. You can combine multiple filters. Note that filters return exact matches only.

  • currrency - the account currency
  • status - the account status
  • created_after - only return accounts created after this date (E.g. 2017-01-01 00:00)
  • created_before - only return accounts created before this date (E.g. 2017-01-01 00:00)

Sample Request

curl https://api.mfsafrica.com/api/accounts?currency=KES -H "Authorization: Token ab594c14986612f6167a975e1c369e71edab6900"
package com.beyonic.samples;

import com.beyonic.exceptions.BeyonicException;
import com.beyonic.models.*;

Beyonic.API_KEY = "ab594c14986612f6167a975e1c369e71edab6900";

String response = null;

try{
    HashMap<String, String> filterValues = new HashMap<>();
    filterValues.put("currency", "KES");
    response = new Account().filter(null, null);
    System.out.println(response);
}
catch (Exception e){
    e.printStackTrace();
}
<?php
require_once('./lib/Beyonic.php');
Beyonic::setApiKey("ab594c14986612f6167a975e1c369e71edab6900");

$accounts = Beyonic_Account::getAll(array(
  "currency" => "KES"
));
?>
import beyonic
beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

accounts = beyonic.Account.list(currency='KES')
require 'beyonic'
Beyonic.api_key = 'ab594c14986612f6167a975e1c369e71edab6900'

accounts = Beyonic::Account.list(
  currency: "KES"
)