Search engine
This functionality allows you to search for responses in JSON format, based on URI parameters.
To work with the search engine, you need to use URI segments of the format
{<keyInYourJson>}
- for required parameters
{<keyInYourJson>
?
}
- for optional parameters.
How to work with it
Let's create an endpoint with a GET
method and the path /api/post/{postId}/comment/{id?}
The response body will look like this:
{
"errors": null,
"responseData": [
{
"id": "1",
"email": "[email protected]",
"createdAt": "822285684",
"content": "sometext"
},
{
"id": "2",
"email": "[email protected]",
"createdAt": "683679219",
"content": "sometext"
},
...
]
}
As you can see, my parameter is named id
, which is identical to the JSON key of the object that is in my response body.
Search logic
To configure the search logic, go to the settings tab.

URI param for searching
Select the URI parameter whose value will be used to search among your JSON response.
Path
Path to a JSON array containing the objects to be searched. In our example, the array of objects is located at level 1, in the responseData
key. In this Path field we write the name of this key - responseData
.
Possible cases:
The array of objects is at level 0 - then the Path field will be empty
The array of objects is at level 2 or more - then the Path field will contain:
<firstKey>.<secondKey>.<thirdKey>
...
Result format
Let's look at 2 options for displaying results:
Array of objects (even if 1 object). The search result will be wrapped in an array, even if one JSON object is found.
Just an object (if more than 1 object is found, only the first one will be displayed).
Testing
Case 1 - I don't pass the parameter because it's optional
GET https://example.migrate.run/api/post/1/comment
// Result format - no difference because there is no URI parameter
{
"errors": null,
"responseData": [
{
"id": "1",
"email": "[email protected]",
"createdAt": "822285684",
"content": "sometext"
},
{
"id": "2",
"email": "[email protected]",
"createdAt": "683679219",
"content": "sometext"
},
...
]
}
Case 2 - I pass a parameter whose value is in one of the objects
GET https://example.migrate.run/api/post/1/comment/1
// Result format - Array of objects
{
"errors": null,
"responseData": [
{
"id": "1",
"email": "[email protected]",
"createdAt": "822285684",
"content": "sometext"
}
]
}
// Result format - Just an object
{
"errors": null,
"responseData": {
"id": "1",
"email": "[email protected]",
"createdAt": "822285684",
"content": "sometext"
}
}
Case 3 - I pass a parameter whose value is not in the objects
GET https://example.migrate.run/api/post/1/comment/200
// Result format - Array of objects
{
"errors": null,
"responseData": []
}
// Result format - Just an object
{
"errors": null,
"responseData": null
}
Last updated