Search for Data
You can also search for specific records in your sheets.
Structuring the search query
Form a JSON string with your search options mapped as {column: value, ...}
. Pass it as the search param to a GET
request to your sheet's API URL.
Performing the request
Let's search for posts by Shiven Sinha in our Blog Posts Sheet.
# Search Sheet1
$ curl 'https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40/Sheet1?search={"author":"Shiven Sinha"}'
# Response ↓ (trimmed for brevity)
# [{"title":"How to create a successful...","content":"Building a good landing page...","link":"https://uxdesign.cc/how-to...","author":"Shiven Sinha"}]
// Search Sheet1
const SteinStore = require("stein-js-client");
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store.read("Sheet1", { search: { author: "Shiven Sinha" } }).then(data => {
console.log(data);
});
// Logs ↓ (trimmed for brevity)
// [{"title":"How to create a successful...","content":"Building a good landing page...","link":"https://uxdesign.cc/how-to...","author":"Shiven Sinha"}]
<script src="https://unpkg.com/stein-js-client"></script>
<script>
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store.read("Sheet1", { search: { author: "Shiven Sinha" } }).then(data => {
console.log(data);
});
// Logs ↓ (trimmed for brevity)
// [{"title":"How to create a successful...","content":"Building a good landing page...","link":"https://uxdesign.cc/how-to...","author":"Shiven Sinha"}]
</script>
Optional request parameters
You can optionally limit and offset your response, as further exemplified in this section.
Parameter | Description | Type |
---|---|---|
limit | Maximum number of rows to be returned | Number (Integer) |
offset | Index of row from which response should start (default is 0) | Number (Integer) |
Return value
An array of objects, with each object representing the matching sheet rows.