Retrieving Multiple Records
You can retrieve multiple records at once - just like the Builder and your Live Apps' table and list views do - by making a GET request to the appropriate object- or view-based URL.
Retrieving Multiple Records: Object-Based GET
Simply make a GET request to a URL like the one below, specifying the object by its key:
URL
GET https://api.knack.com/v1/objects/object_xx/records
Parameters
Parameter | Explanation | Example |
---|---|---|
object_xx | object key | object_1 |
Headers
Key | Value |
---|---|
X-Knack-Application-Id | Your application ID |
X-Knack-REST-API-KEY | Your API key |
Example Request
curl -X GET "https://api.knack.com/v1/objects/object_1/records" \
-H "X-Knack-Application-Id: YOUR-APP-ID" \
-H "X-Knack-REST-API-Key: YOUR-API-KEY"
Example Response (200 OK)
Note that this is abbreviated - only two records are included out of the response's fourteen.
Read more about how to interpret this information here.
{
"total_pages": 1,
"current_page": 1,
"total_records": 14,
"records": [
{
"id": "58643557d1ea9432222f3cc0",
"field_1": "Dodgit",
"field_1_raw": "Dodgit",
"field_16": "334 Menlo Drive<br />Menlo, CA 84432",
"field_16_raw": {
"longitude": -111.97383,
"latitude": 41.223,
"street": "334 Menlo Drive",
"street2": "",
"city": "Menlo",
"state": "CA",
"zip": "84432"
},
"field_17": "<a href=\"http://www.dodgit.com\" target=\"_blank\">http://www.dodgit.com</a>",
"field_17_raw": {
"url": "http://www.dodgit.com"
},
"field_18": "Entertainment",
"field_18_raw": "Entertainment",
"field_31": "717-443-5567",
"field_31_raw": "717-443-5567"
},
{
"id": "58643557d1ea9432222f3cbe",
"field_1": "Ejecta",
"field_1_raw": "Ejecta",
"field_16": "689 Marshville Road<br />Spring Valley, NY 10977",
"field_16_raw": {
"street": "689 Marshville Road",
"city": "Spring Valley",
"state": "NY",
"zip": "10977",
"latitude": 41.130548,
"longitude": -74.051227
},
"field_17": "<a href=\"http://www.ejecta.com\" target=\"_blank\">http://www.ejecta.com</a>",
"field_17_raw": {
"url": "http://www.ejecta.com"
},
"field_18": "Tech",
"field_18_raw": "Tech",
"field_31": "845-579-3734",
"field_31_raw": "845-579-3734"
},
..........
]
}
Retrieving Multiple Records: View-Based GET
You can retrieve multiple records by sending a GET request to a view’s route. The following views can display multiple records:
- Tables
- Lists
- Searches
- Calendars
Note that the only fields included in the response will be those included in the view specified in your URL, and that the view's source will impact the records which your requests retrieve.
URL
GET https://api.knack.com/v1/pages/scene_xx/views/view_yy/records
Parameters
Headers
Key | Value |
---|---|
X-Knack-Application-Id | Your application ID |
X-Knack-REST-API-KEY | knack |
Authorization | A user token valid for the view (if view is nested under a login) |
Example Request
curl -X GET "https://api.knack.com/v1/pages/scene_1/views/view_11/records" \
-H "X-Knack-Application-Id: YOUR-APP-ID" \
-H "X-Knack-REST-API-Key: knack"
Example Response (200 OK)
Note that this is abbreviated - only two records are included out of the response's fourteen.
Also note that are fields included here which do not appear in the response to our object-based GET requests; this is because the table used in this example - the Companies table - includes a column for Contacts.
{
"total_pages": 1,
"current_page": 1,
"total_records": 15,
"records": [
{
"id": "58643557d1ea9432222f3cb5",
"field_1": "BASCO",
"field_1_raw": "BASCO",
"field_16": "4295 Drainer Avenue<br />Tallahassee, FL 32304",
"field_16_raw": {
"longitude": -84.177903,
"latitude": 30.463511,
"zip": "32304",
"state": "FL",
"city": "Tallahassee",
"street2": "",
"street": "4295 Drainer Avenue"
},
"field_17": "<a href=\"http://www.basco.com\" target=\"_blank\">http://www.basco.com</a>",
"field_17_raw": {
"url": "http://www.basco.com"
},
"field_18": "Entertainment",
"field_18_raw": "Entertainment",
"field_14_raw": [
{
"first": "Barbara",
"last": "Waters"
},
{
"first": "Josefa",
"last": "Willems"
}
],
"field_14": "<a href=\"#58643557d1ea9432222f3cd1\"><span id=\"58643557d1ea9432222f3cd1\">Barbara Waters</span></a><br /><a href=\"#58643558d1ea9432222f3ce9\"><span id=\"58643558d1ea9432222f3ce9\">Josefa Willems</span></a>"
},
{
"id": "58643557d1ea9432222f3cb1",
"field_1": "Cavages",
"field_1_raw": "Cavages",
"field_16": "3885 Mount Street<br />Saginaw, MI 48607",
"field_16_raw": {
"street": "3885 Mount Street",
"city": "Saginaw",
"state": "MI",
"zip": "48607",
"latitude": 44.352592,
"longitude": -84.419193
},
"field_17": "<a href=\"http://www.cavages.com\" target=\"_blank\">http://www.cavages.com</a>",
"field_17_raw": {
"url": "http://www.cavages.com"
},
"field_18": "Health Care",
"field_18_raw": "Health Care",
"field_14_raw": [
{
"first": "Daniel",
"last": "Navarrete"
},
{
"first": "Mark",
"last": "Silverstein"
}
],
"field_14": "<a href=\"#58643557d1ea9432222f3ccc\"><span id=\"58643557d1ea9432222f3ccc\">Daniel Navarrete</span></a><br /><a href=\"#58643558d1ea9432222f3cd9\"><span id=\"58643558d1ea9432222f3cd9\">Mark Silverstein</span></a>"
},
..........
Updated about 4 years ago