GET
/branches
Auth Required

List Branches

Get a paginated list of all hotel branches. Supports filtering, searching, and pagination.

Scopes: branch:read
Rate Limit: 60 per minute

Request/Response Examples

Paginated list of branches.

JSON
{
    "status": "success",
    "data": {
        "data": [
            {
                "id": 1,
                "branch_code": "NRB001",
                "branch_name": "Nairobi City Hotel",
                "location": "Nairobi CBD"
            }
        ],
        "pagination": {
            "current_page": 1,
            "per_page": 15,
            "total": 6
        }
    },
    "code": 200
}

Code Examples

PHP - List Branches

PHP example for listing branches

<?php
$token = "YOUR_JWT_TOKEN_HERE";

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://hotel.webninjaafrica.com/api/branches?page=1&per_page=15",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . $token,
        "Content-Type: application/json"
    ]
]);

$response = curl_exec($curl);
$branches = json_decode($response, true);

foreach ($branches["data"]["data"] as $branch) {
    echo $branch["branch_name"] . " - " . $branch["location"] . "\n";
}

curl_close($curl);
?>
Python - List Branches

Python example for listing branches

import requests

token = "YOUR_JWT_TOKEN_HERE"
url = "https://hotel.webninjaafrica.com/api/branches"
headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers, params={"page": 1, "per_page": 15})
data = response.json()

if data["status"] == "success":
    for branch in data["data"]["data"]:
        print(f"{branch['branch_name']} - {branch['location']}")
else:
    print("Error: " + data["message"])
Node.js - List Branches

Node.js example for listing branches

const axios = require("axios");

async function getBranches(token) {
    try {
        const response = await axios.get("https://hotel.webninjaafrica.com/api/branches", {
            headers: {
                "Authorization": `Bearer ${token}`,
                "Content-Type": "application/json"
            },
            params: {
                page: 1,
                per_page: 15
            }
        });
        
        if (response.data.status === "success") {
            response.data.data.data.forEach(branch => {
                console.log(`${branch.branch_name} - ${branch.location}`);
            });
        }
    } catch (error) {
        console.error("Error:", error.response?.data?.message || error.message);
    }
}
cURL - List Branches

cURL example for listing branches

curl -X GET "https://hotel.webninjaafrica.com/api/branches?page=1&per_page=15" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"