Data Store - Table Records

 

Get Data Store Table Records

This endpoint allows you to pull records from any table in the Data Store.

Note that the data store APIs utilize OAuth 2.0 for authorization. OAuth 2.0 credentials can be provisioned in Kahua by a Kahua Domain Administrator. Pleaserefer to Authentication for more details on using OAuth 2.0.

Operation

GET

Endpoint

/api/v1/datastore/table/{appName}/{entityName}/api/v1/datastore/table/{tablename}

This endpoint can accept either a data store table name, or an app name and entity name. The data store table name is created in the form {appName}_{entityName}. For instance, the table name for the Contract entity in the kahua_Contract app would be kahua_Contract_Contract .

A list of table names in the data store can be retrieved using the Table List endpoint.

 

Path Parameters

Parameter Type Description
appName string The name of the app where the desired entity is defined.
entityName string The name of the entity being queried.

Query Parameters

Parameter Type Description Default
fields string Comma-separated list of field or attribute names to include in the results. All
orderBy string Comma-separated list of fields used to sort the results. Optionally append a space and 'DESC' to one or more fields to sort by that field in descending order. ID
offset integer The number of records to skip. This is used for paging the data. 0
limit integer The maximum number of records to return. 1000
where string A filter to be applied to the results. This uses standard SQL syntax. (none)

NOTE: The query parameters require URL encoding if any invalid characters are used in the query. For instance, spaces should be encoded with a %20 encoding to ensure the URL remains valid.

Request Body

None  

Response Body

The response will be a JSON object with the following fields:

Field Name Description
recordCount The number of records contained in this response
totalRecordCount The total number of records that would match this query without limit or offset applied
records An array of JSON objects, each representing a record in the Data Store

 

Copy
{
  "recordCount": 10,
  "totalRecordCount": 512,
  "records": [
    {
      "Id": 1.
      ...
    },
    {
      "Id": 2,
      ...
    }
  ]
}

If the table specified does not exist in the data store, then the response will return a 404 Not Found error code.

If the Accept header is text/csv then the response will be in CSV format, and will contain only the records with column names. Record counts will not be included with CSV data.

Id,DomainPartitionId,PartitionId,...
1,1,1...
2,1,1...

The Data Store must be enabled for the entity type being queried

Alternative option to query for a single record

If the ID is included at the end of the URL, then only a single record will be returned, rather than an array.

/api/v1/datastore/table/{appName}/{entityName}/{id}

Associative Tables

Associative tables can also be queried, but they do not have ID values, so single-record queries are not supported.

/api/v1/datastore/table/{appName}/{entityName}.{linkName}

Possible Status Codes

  • 200 - Successful call

  • 401 - Unauthorized, most likely due to invalid credentials

  • 404 - Table not found

  • 400 - Other failure in call

Examples

Request the first 1000 Contracts in the domain, ordered by their ID. https://service.kahua.com/api/v1/datastore/table/kahua_Contract/Contract

Request the next 500 Contracts in the domain, after the first 1000. https://service.kahua.com/api/v1/datastore/table/kahua_Contract/Contract?offset=1000&limit=500

Request the ID and Type of the 5 most recently created Contracts in the domain. https://service.kahua.com/api/v1/datastore/table/kahua_Contract/Contract?limit=5&orderBy=CreatedDateTime%20DESC&fields=Id,Type

Request a specific Contract https://service.kahua.com/api/v1/datastore/table/kahua_Contract/Contract/12653779

Request the Items associations for the same Contract https://service.kahua.com/api/v1/datastore/table/kahua_Contract/Contract.Items?where=Contract_Id=12653779