Search An Entity

POST /api/v1/{entity-name}/search

Or GET /api/v1/{entity-name}/search?search=<base64 encoded payload>

Path Parameters

NameTypeDescription

entity-name*

String

Name of the entity to be searched

Headers

NameTypeDescription

content-type*

String

Set to application/json

Query Parameters

NameTypeDescription

search

base64 encoded payload

Sets the query for searching and pagination of the data. example: eyJvZmZzZXQiOjIsImxpbWl0IjoyLCJmaWx0ZXJzIjp7fSwiZW50aXR5VHlwZSI6WyJJbnN1cmFuY2UiXX0= contains { "offset": 2, "limit": 2, "filters": { } }

Request Body

NameTypeDescription

...*

Object

Filters to be sent in order to identify an entity

{
    "totalCount": 10,
    "nextPage": "<registry-url>/api/v1/Student?search=<base64 encoded search payload>",
    "prevPage": "<registry-url>/api/v1/Student?search=<base64 encoded search payload>",
    "data": [
        {
            "school": "UP Public School",
            "name": "Pranav Agate",
            "contact": "1234567890",
            "subject": "Math",
            "osid": "{id}",
            "osOwner": ["{osOwner}"]
        }
    ]
}

Sample Request Body

{ "filters": { "school": { "eq": "UP Public School" } }, "limit": 1, "offset": 0 }

Important Fields in Request Body

FieldTypeDescription

limit

Number

Number of responses to be retrieved out of total number of search results

offset

Number

Starting point for responses to be returned

viewTemplateId

String

Any operation to be carried on the response before it is returned via API, that can be provided here. For eg: Combining First Name and Last Name into Single Field Name

Filter Operators

String

eq, neq, gte, gt, lte, lt, contains, notContains, between, or, startsWith, notStartsWith, endsWith, notEndsWith, queryString are some of the operators provided

Usage

cURL

curl --location \
    --request POST \
    --header 'Content-Type: application/json' \
    '{registry-url}/api/v1/Place/search' \
    --data-raw '{
        "filters": {
            "name": {
                "eq": "UP Public School"
            }
        },
        "limit": 1,
        "offset": 0
    }'

HTTPie

printf '{
    "filters": {
        "school": {
            "eq": "UP Public School"
        }
    },
    "limit": 1,
    "offset": 0
}'| http POST '{registry-url}/api/v1/Place/search' \
 Content-Type:'application/json' \

{registry-url} is usually http://localhost:{port}. The port can be found under the registry section in the docker-compose.yml file and is usually 8081.

Last updated

Copyright (c) 2023 EkStep Foundation under MIT License