Get Data using API

After having your API Token, refer to this doc to read the data that you need.

Sql Query API

Method: POST

Path:

https://[client].datainsider.co/api/query/sql

ParameterTypeDescription

api_key

string

API key that has database permission

sql

string

sql query to data warehouse

Sample request:

curl --request POST \
  --url https://[client].datainsider.co/api/query/sql \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "cccccccc-14a1-4eb1-8964-000000000000",
    "sql": "select * from transactions.orders limit 0, 10"
}'

Sample response:

{
    "headers": [
   	 "id",
   	 "item_name",
   	 "status",
   	 "type",
   	 "amount",
   	 "creator_id",
   	 "created",
   	 "last_modified"
    ],
    "records": [
   	 [
   		 1,
   		 "pencil",
   		 "ordered",
   		 "A",
   		 99.0,
   		 "user_a",
   		 1647229177000,
   		 1647229777000
   	 ],
   	 [
   		 2,
   		 "paper",
   		 "shipped",
   		 "A",
   		 100.0,
   		 "user_b",
   		 1647229179000,
   		 1647234772000
   	 ]
    ]
}

Update Data API

Method: PUT

Path:

https://[client].datainsider.co/api/databases/<db_name>/tables/<tbl_name>/rows

ParameterTypeDescription

db_name

string

name of the database that contains the table

tbl_name

string

name of the table

api_key

string

API key that has database permission

updated_rows

json string array

list of rows that need to be updated

Note:

  • To perform the update correctly, it is necessary to set the primary keys of the specified table in the Schema Management section to determine the correct row to update. Primary keys can be one or more columns.

  • By default, when retrieving data (from the api or displayed on a chart), the value of the last update will be displayed. To view full historical information of updated rows, it is necessary to enable Historical Data mode in the Chart Setting of each chart to view full history.

Sample request:

curl --request PUT \
  --url http://[client].datainsider.co/api/databases/client_db/tables/orders/rows \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "cccccccc-14a1-4eb1-8964-000000000000",
    "updated_rows": [
   	 ["100", "item1", "1647143817000", "shipped"],
   	 ["101", "item2", "1647143818000", "delivering"],
   	 ["102", "item3", "1647143819000", "packaging"]
    ]
}'

Note: Schema of the orders table in this example: order_id (primary_key) | item_name | updated_time | status

Sample response:

{
  "success": true
}

Last updated