NAV -image
javascript php

Introduction

This documentation aims to provide all the information you need to work with our API.

Base URL

https://development.zanifu.com/

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer {YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve the token from the response of a valid login.

Authentication

Api for authenticating users.

Validate user credentials

Example request:

const url = new URL(
    "https://development.zanifu.com/api/login"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "key": "labore",
    "email": "omnis",
    "phone": "quia",
    "password": "harum",
    "secret": "et"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/login',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'key' => 'labore',
            'email' => 'omnis',
            'phone' => 'quia',
            'password' => 'harum',
            'secret' => 'et',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/login

Body Parameters

key  string optional  
This can also be email|phone

email  string optional  
This can also be phone|key

phone  string optional  
This can also be email|key

password  string optional  
This can also be secret

secret  string optional  
This can also be password

Register new distributor

Example request:

const url = new URL(
    "https://development.zanifu.com/api/sign-up"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "account_type": 12,
    "name": "illum",
    "phone": "voluptatibus",
    "email": "temporibus"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/sign-up',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'account_type' => 12,
            'name' => 'illum',
            'phone' => 'voluptatibus',
            'email' => 'temporibus',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/sign-up

Body Parameters

account_type  integer optional  

name  string optional  
Distributor Name

phone  string optional  
Distributor Phone number

email  string optional  
Distributor Email

Initiate a password reset request

Example request:

const url = new URL(
    "https://development.zanifu.com/api/password-reset"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "aut"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/password-reset',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'email' => 'aut',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/password-reset

Body Parameters

email  string  
Distributor Email

Complete password reset

Example request:

const url = new URL(
    "https://development.zanifu.com/api/reset-password"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "dolorum",
    "token": "nihil",
    "new_password": "rerum"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/reset-password',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'email' => 'dolorum',
            'token' => 'nihil',
            'new_password' => 'rerum',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/reset-password

Body Parameters

email  string  
Distributor Email

token  string  
Generated token from email

new_password  string  
New password

Change the current user password

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/change-password"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "current_password": "qui",
    "new_password": "et"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/change-password',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'current_password' => 'qui',
            'new_password' => 'et',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/change-password

Body Parameters

current_password  string  
Current user password

new_password  string  
New user password

Log out the distributor.

requires authentication

Remove current distributor token

Example request:

const url = new URL(
    "https://development.zanifu.com/api/logout"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/logout',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/logout

Cart

List carts

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/carts"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/carts',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/carts

Get single cart details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/carts/3"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/carts/3',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/carts/{cart}

URL Parameters

cart  integer  
Cart id

Categories

List of categories

Example request:

const url = new URL(
    "https://development.zanifu.com/api/categories"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/categories',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):

{
    "data": [
        {
            "id": 1,
            "name": "Bakeries"
        },
        {
            "id": 2,
            "name": "Barber and Beauty Shops"
        },
        {
            "id": 3,
            "name": "Butchery and Meat supplies"
        },
        {
            "id": 4,
            "name": "Book Stores"
        },
        {
            "id": 5,
            "name": "Carwash and Dry Cleaners"
        },
        {
            "id": 6,
            "name": "Chemicals and Allied Products"
        },
        {
            "id": 7,
            "name": "Children’s and Infant’s Wear Stores"
        },
        {
            "id": 8,
            "name": "Cigar Stores and suppliers"
        },
        {
            "id": 9,
            "name": "Commercial Footwear"
        },
        {
            "id": 10,
            "name": "Computers, Computer Peripheral Equipment, Software"
        },
        {
            "id": 11,
            "name": "Dairy Products Stores"
        },
        {
            "id": 12,
            "name": "Drinking Places (Alcoholic Beverages), Bars, Taverns, Cocktail lounges, Nightclubs and Discotheques"
        },
        {
            "id": 13,
            "name": "Drug Stores and Pharmacies"
        },
        {
            "id": 14,
            "name": "Eating places and Restaurants"
        },
        {
            "id": 15,
            "name": "Electrical Parts and Equipment"
        },
        {
            "id": 16,
            "name": "Fast Food Restaurants"
        },
        {
            "id": 17,
            "name": "Florists’ Supplies, Nursery Stock and Flowers"
        },
        {
            "id": 18,
            "name": "Glassware\/Crystal Stores"
        },
        {
            "id": 19,
            "name": "Hardware Stores"
        },
        {
            "id": 20,
            "name": "Health and Beauty Shops"
        },
        {
            "id": 21,
            "name": "Household Appliance Stores"
        },
        {
            "id": 22,
            "name": "Industrial Supplies"
        },
        {
            "id": 23,
            "name": "Medical, Dental Ophthalmic, Hospital Equipment and Supplies"
        },
        {
            "id": 24,
            "name": "Men’s Women’s and Children’s Uniforms and Commercial Clothing"
        },
        {
            "id": 25,
            "name": "Misc. General Merchandise"
        },
        {
            "id": 26,
            "name": "Motorcycle Dealers"
        },
        {
            "id": 27,
            "name": "Motor vehicle supplies and new parts"
        },
        {
            "id": 28,
            "name": "Package Stores - Beer, Wine, and Liquor"
        },
        {
            "id": 29,
            "name": "Paints, Varnishes, and Supplies"
        },
        {
            "id": 30,
            "name": "Petroleum and Petroleum Products"
        },
        {
            "id": 31,
            "name": "Phones and Electronic Sales"
        },
        {
            "id": 32,
            "name": "Plumbing and Heating Equipment and Supplies"
        },
        {
            "id": 33,
            "name": "Sports Apparel Stores"
        },
        {
            "id": 34,
            "name": "Stationery, Office Supplies, Printing, and Writing Paper"
        },
        {
            "id": 35,
            "name": "Supermarkets"
        },
        {
            "id": 36,
            "name": "Welding and Repair"
        }
    ]
}

Request      

GET api/categories

Checkout

Get till details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/tills/6"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/tills/6',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/tills/{till}

URL Parameters

till  integer  
Till Number

Checkout

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/checkout"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "payment_method": "mpesa",
    "till": 12345,
    "phone_number": "+254123456789",
    "products": [
        {
            "id": 13,
            "quantity": 5
        },
        {
            "id": 13,
            "quantity": 5
        }
    ]
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/checkout',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'payment_method' => 'mpesa',
            'till' => 12345,
            'phone_number' => '+254123456789',
            'products' => [
                [
                    'id' => 13,
                    'quantity' => 5,
                ],
                [
                    'id' => 13,
                    'quantity' => 5,
                ],
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/checkout

Body Parameters

payment_method  string  
Payment Method (mpesa, zanifu_credit, pay_later)

till  integer  
Distributor Till Number

phone_number  string optional  
Alternative Phone Number

products  object[]  
Products selected for payment

products[].id  integer  

products[].quantity  integer  

Customers

Customer summary per region

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/customers"
);

let params = {
    "page[number]": "18",
    "page[size]": "19",
    "filter[search]": "velit",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/customers',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '18',
            'page[size]'=> '19',
            'filter[search]'=> 'velit',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/customers

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[search]  string optional  
Filter by query

Customer transactions

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/customers/19/transactions"
);

let params = {
    "page[number]": "12",
    "page[size]": "18",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/customers/19/transactions',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '12',
            'page[size]'=> '18',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/customers/{customer}/transactions

URL Parameters

customer  integer  
Customer ID

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

Customers in a region

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/customers/1"
);

let params = {
    "page[number]": "5",
    "page[size]": "18",
    "filter[search]": "quam",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/customers/1',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '5',
            'page[size]'=> '18',
            'filter[search]'=> 'quam',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/customers/{region}

URL Parameters

region  integer  
Region ID

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[search]  string optional  
Filter by query

Endpoints

Distributor dashboard

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/dashboard"
);

let params = {
    "filters[period]": "monthly",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/dashboard',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'filters[period]'=> 'monthly',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/dashboard

Query Parameters

filters[period]  string optional  
Filter by transaction period

Sales summary

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/sales"
);

let params = {
    "filters[period]": "monthly",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/sales',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'filters[period]'=> 'monthly',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/sales

Query Parameters

filters[period]  string optional  
Filter by transaction period

Stock credit summary

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/stock-credit"
);

let params = {
    "filters[period]": "monthly",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/stock-credit',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'filters[period]'=> 'monthly',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/stock-credit

Query Parameters

filters[period]  string optional  
Filter by transaction period

Stock credit details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/finance/stock-credit"
);

let params = {
    "page[number]": "12",
    "page[size]": "18",
    "filter[start_date]": "2021-06-01",
    "filter[end_date]": "2021-06-30",
    "filter[search]": "rerum",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/finance/stock-credit',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '12',
            'page[size]'=> '18',
            'filter[start_date]'=> '2021-06-01',
            'filter[end_date]'=> '2021-06-30',
            'filter[search]'=> 'rerum',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/finance/stock-credit

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[start_date]  string optional  
date Filter start date

filter[end_date]  string optional  
date Filter end date

filter[search]  string optional  
Filter by query

Export credit sales

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/finance/stock-credit/export"
);

let params = {
    "filter[start_date]": "2021-06-01",
    "filter[end_date]": "2021-06-30",
    "filter[search]": "illo",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/finance/stock-credit/export',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'filter[start_date]'=> '2021-06-01',
            'filter[end_date]'=> '2021-06-30',
            'filter[search]'=> 'illo',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/finance/stock-credit/export

Query Parameters

filter[start_date]  string optional  
date Filter start date

filter[end_date]  string optional  
date Filter end date

filter[search]  string optional  
Filter by query

Sales details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/finance/sales"
);

let params = {
    "page[number]": "17",
    "page[size]": "10",
    "filter[start_date]": "2021-06-01",
    "filter[end_date]": "2021-06-30",
    "filter[search]": "aut",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/finance/sales',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '17',
            'page[size]'=> '10',
            'filter[start_date]'=> '2021-06-01',
            'filter[end_date]'=> '2021-06-30',
            'filter[search]'=> 'aut',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/finance/sales

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[start_date]  string optional  
date Filter start date

filter[end_date]  string optional  
date Filter end date

filter[search]  string optional  
Filter by query

List of orders

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/orders"
);

let params = {
    "page[number]": "12",
    "page[size]": "6",
    "filter[start_date]": "2021-06-01",
    "filter[end_date]": "2021-06-30",
    "filter[search]": "et",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/orders',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '12',
            'page[size]'=> '6',
            'filter[start_date]'=> '2021-06-01',
            'filter[end_date]'=> '2021-06-30',
            'filter[search]'=> 'et',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/orders

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[start_date]  string optional  
date Filter start date

filter[end_date]  string optional  
date Filter end date

filter[search]  string optional  
Filter by query

api/orders/{order}

Example request:

const url = new URL(
    "https://development.zanifu.com/api/orders/et"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "PATCH",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->patch(
    'https://development.zanifu.com/api/orders/et',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

PATCH api/orders/{order}

URL Parameters

order  string  

Loans

All user loans

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/loans"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/loans',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/loans

Make Loan Payment

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/loans"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "amount": "2",
    "phone_number": "+254123456789"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/loans',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'amount' => '2',
            'phone_number' => '+254123456789',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/loans

Body Parameters

amount  string  
Amount being paid

phone_number  string optional  
Alternative Phone Number

Check loan limit

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/loans/limit"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/loans/limit',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/loans/limit

Merchants

Api for managing merchants.

Register a new merchant.

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "phone_number": "vel",
    "pin": "rerum",
    "category_id": "explicabo"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/merchants',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'phone_number' => 'vel',
            'pin' => 'rerum',
            'category_id' => 'explicabo',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/merchants

Body Parameters

phone_number  string  

pin  string  

category_id  string  

Update merchant details.

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants15"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "merchant_name": "omnis",
    "business_name": "aut",
    "email": "eligendi",
    "location": "cupiditate"
}

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->put(
    'https://development.zanifu.com/api/merchants15',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'merchant_name' => 'omnis',
            'business_name' => 'aut',
            'email' => 'eligendi',
            'location' => 'cupiditate',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

PUT api/merchants{merchant}

URL Parameters

merchant  integer  

Body Parameters

merchant_name  string  

business_name  string  

email  string  

location  string  

Get application status.

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants/6/application"
);

let headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/merchants/6/application',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/merchants/{merchant}/application

URL Parameters

merchant  integer  

Upload merchant ID

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants/10/national-id"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('front', document.querySelector('input[name="front"]').files[0]);
body.append('back', document.querySelector('input[name="back"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/merchants/10/national-id',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'front',
                'contents' => fopen('/tmp/phpBvOiJy', 'r')
            ],
            [
                'name' => 'back',
                'contents' => fopen('/tmp/phpDYfKgz', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/merchants/{merchant}/national-id

URL Parameters

merchant  integer  

Body Parameters

front  file  

back  file  

Upload business permit

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants/4/business-permit"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('business_permit', document.querySelector('input[name="business_permit"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/merchants/4/business-permit',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'business_permit',
                'contents' => fopen('/tmp/phpRvs76y', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/merchants/{merchant}/business-permit

URL Parameters

merchant  integer  

Body Parameters

business_permit  file  

Upload mpesa statement

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants/14/mpesa-statement"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('business_permit', document.querySelector('input[name="business_permit"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/merchants/14/mpesa-statement',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'business_permit',
                'contents' => fopen('/tmp/phpaCjTGz', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/merchants/{merchant}/mpesa-statement

URL Parameters

merchant  integer  

Body Parameters

business_permit  file  

Upload other files

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/merchants/18/other-documents"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('files[]', document.querySelector('input[name="files[]"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/merchants/18/other-documents',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'files[]',
                'contents' => fopen('/tmp/phpRpgAny', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/merchants/{merchant}/other-documents

URL Parameters

merchant  integer  

Body Parameters

files[]  file  

Products

Api for managing products.

List of products

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/products"
);

let params = {
    "filter[category]": "4",
    "filter[distributor]": "2",
    "page[number]": "19",
    "page[size]": "20",
    "filter[search]": "rerum",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/products',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'filter[category]'=> '4',
            'filter[distributor]'=> '2',
            'page[number]'=> '19',
            'page[size]'=> '20',
            'filter[search]'=> 'rerum',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/products

Query Parameters

filter[category]  integer optional  
Filter by category

filter[distributor]  integer optional  
Filter by distributor

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[search]  string optional  
Filter by query

Add a new product

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/products"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "title": "nam",
    "description": "fugit",
    "price": 11,
    "distributor_id": 1,
    "category_id": 13
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/products',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'title' => 'nam',
            'description' => 'fugit',
            'price' => 11,
            'distributor_id' => 1,
            'category_id' => 13,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/products

Body Parameters

title  string  
Product Title

description  string optional  
Product description

price  integer  
Product price

distributor_id  integer  
Product distributor

category_id  integer  
Product category

Get single product details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/products/5"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/products/5',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/products/{product}

URL Parameters

product  integer  
Product id

Update a product

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/products/quas"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "title": "sit",
    "description": "facere",
    "price": 6,
    "distributor_id": 3,
    "category_id": 4
}

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->put(
    'https://development.zanifu.com/api/products/quas',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'title' => 'sit',
            'description' => 'facere',
            'price' => 6,
            'distributor_id' => 3,
            'category_id' => 4,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

PUT api/products/{product}

PATCH api/products/{product}

URL Parameters

product  string  

Body Parameters

title  string  
Product Title

description  string optional  
Product description

price  integer  
Product price

distributor_id  integer  
Product distributor

category_id  integer  
Product category

Delete a product

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/products/16"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->delete(
    'https://development.zanifu.com/api/products/16',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

DELETE api/products/{product}

URL Parameters

product  integer  
product id

Users

Api for managing users.

Show all users

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/users"
);

let params = {
    "page[number]": "9",
    "page[size]": "6",
    "filter[search]": "et",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/users',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page[number]'=> '9',
            'page[size]'=> '6',
            'filter[search]'=> 'et',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/users

Query Parameters

page[number]  integer optional  
Page number

page[size]  integer optional  
Number of records on a page

filter[search]  string optional  
Filter by query

Create a new user

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/users"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "first_name": "autem",
    "last_name": "labore",
    "email": "aut",
    "phone_number": "adipisci",
    "is_admin": false,
    "permissions": "['sales','orders']"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->post(
    'https://development.zanifu.com/api/users',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'first_name' => 'autem',
            'last_name' => 'labore',
            'email' => 'aut',
            'phone_number' => 'adipisci',
            'is_admin' => false,
            'permissions' => '[\'sales\',\'orders\']',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

POST api/users

Body Parameters

first_name  string  
User's first name

last_name  string  
User's last name

email  string  
User's email

phone_number  string  
User's phone number

is_admin  boolean  
If user is an admin

permissions  array optional  
Permissions for non admin

Get single user details

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/users/3"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->get(
    'https://development.zanifu.com/api/users/3',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (401):

{
    "message": "Unauthenticated."
}

Request      

GET api/users/{user}

URL Parameters

user  integer  
User's id

Update user details.

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/users/quidem"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "first_name": "aperiam",
    "last_name": "delectus",
    "phone_number": "consequuntur",
    "is_admin": false,
    "permissions": "['sales','orders']",
    "email": "impedit"
}

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->put(
    'https://development.zanifu.com/api/users/quidem',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'first_name' => 'aperiam',
            'last_name' => 'delectus',
            'phone_number' => 'consequuntur',
            'is_admin' => false,
            'permissions' => '[\'sales\',\'orders\']',
            'email' => 'impedit',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

PUT api/users/{user}

PATCH api/users/{user}

URL Parameters

user  string  

Body Parameters

first_name  string  
User's first name

last_name  string  
User's last name

phone_number  string  
User's phone number

is_admin  boolean  
If user is an admin

permissions  array optional  
Permissions for non admin

email  string  
User's email

Deactivate a user

requires authentication

Example request:

const url = new URL(
    "https://development.zanifu.com/api/users/17"
);

let headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

$client = new \GuzzleHttp\Client();
$response = $client->delete(
    'https://development.zanifu.com/api/users/17',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Request      

DELETE api/users/{user}

URL Parameters

user  integer  
user id