v3/Location API's

Get All Locations

Overview

This API endpoint allows you to fetch all locations in a single call, returning an array of objects with the full hierarchy: site, building, floor, room, and bed.

Endpoint Details

Method

GET

URL

https://api.mosler.in/api/v3/location/all

Authentication

Headers

NameTypeRequiredDescription
apikeystringYesYour API key for authentication
Content-TypestringNoapplication/json

Query Parameters

NameTypeRequiredDescription
pagenumberNoPage number for pagination (default: 1)
limitnumberNoNumber of locations per page (default: 100, max: 100)

Response Format

Success Response

NameTypeDescription
messagestringSuccess message describing the operation
codenumberStatus code indicating successful operation
errorbooleanAlways false for successful responses
dataobjectObject containing locations data and pagination info

Data Object Structure

NameTypeDescription
locationsarrayArray of location objects
paginationobjectPagination information
totalnumberTotal number of locations available

Location Object Structure

NameTypeDescription
siteobjectSite object { name, _id }
buildingobjectBuilding object { name, _id }
floorobjectFloor object { name, _id }
roomobjectRoom object { name, _id }
bedobjectBed object { name, _id }

Pagination Object Structure

NameTypeDescription
currentPagenumberCurrent page number
totalPagesnumberTotal number of pages available
hasNextbooleanWhether there are more pages
hasPreviousbooleanWhether there are previous pages

Response Examples

Successful Response

{
    "message": "Locations retrieved successfully",
    "code": 7010,
    "error": false,
    "data": {
        "locations": [
            {
                "site": { "name": "Delhi", "_id": "6530f9dce0c1bd73ded0d1be" },
                "building": {
                    "name": "Main Tower",
                    "_id": "6530f9dce0c1bd73ded0d1be"
                },
                "floor": {
                    "name": "First Floor",
                    "_id": "6530f9dce0c1bd73ded0d1be"
                },
                "room": { "name": "101", "_id": "6530f9dce0c1bd73ded0d1be" },
                "bed": { "name": "Bed 1", "_id": "6530f9dce0c1bd73ded0d1be" }
            }
        ],
        "pagination": {
            "currentPage": 1,
            "totalPages": 1,
            "hasNext": false,
            "hasPrevious": false
        },
        "total": 1
    }
}