The Glide Tables API is available to anyone with the Pro, Business, or Enterprise plan. Connecting to your Glide Tables via the API allows you to automate your data management and integrate it with your own applications.
Using Glide Tables API
You can leverage Glide Tables API in lots of different ways. Let’s break down a few different possibilities together.
New to APIs? If you want a step-by-step guide for setting up an API automation tool and using each call, check out this article
Mutations
The mutateTables
call in each Glide curl statement adds one or more mutation operation for tables in an app in Glide's queue. After they're added to the queue, they can be processed anytime after the call returns the actions.
This call takes a JSON body of the following form:
1 {
2 "appID": "APP-ID",
3 "mutations": [MUTATION, ...]
4 }
At least one mutation must be given. Glide doesn’t support more than 500 mutations in one invocation.
The call will succeed if all mutations succeed. It will fail if even one mutation fails. It will return a JSON response that's an array of results—one for each mutation. If a mutation fails, then its result has a property error. which is an error
message.
Keep in mind:
- Actions that are enqueued are not guaranteed to succeed. For example, an action to delete a row that does not exist might successfully be queued. However, it will not be processed successfully since there is nothing to delete.
- Actions are not guaranteed to be processed in sequence. For example, two added rows will not necessarily be added in the order they are given in the
mutations
array.
Mutations available in the Glide Tables API include add-row-to-table
, set-columns-in-row
, and delete-row
.
Add rows
The add-row-to-table
mutation adds one row to your table.
1 {
2 "kind": "add-row-to-table",
3 "tableName": "TABLE-NAME",
4 "columnValues": {
5 "COLUMN-NAME": "COLUMN-VALUE",
6 ...
7 }
8 }
If the table has a Row ID
column and the call is successful, the result will have a property rowID
with the row ID
of the row to be added.
Not all columns have to be specified. Columns that are not set will remain empty or unchanged.
Set columns
The set-columns-in-row
mutation sets one or more columns in an existing row in your table.
1 {
2 "kind": "set-columns-in-row",
3 "tableName": "TABLE-NAME",
4 "columnValues": {
5 "COLUMN-NAME": "COLUMN-VALUE",
6 ...
7 },
8
9 ROW-ID-OR-INDEX
10 }
The ROW-ID-OR-INDEX
is one of the following:
"rowID": "ROW-ID"
"rowIndex": ROW-INDEX"
ROW-INDEX
should only be used for Google Sheet tables. It must be a number, and it's zero-based, i.e. the first row in the sheet has index 0
.
Delete rows
The delete-row
mutation deletes an existing row from your table.
1. {
2. "kind": "delete-row",
3. "tableName": "TABLE-NAME",
4. ROW-ID-OR-INDEX
5. }
ROW-ID-OR-INDEX
is interpreted identically to set-columns-in-row
.
Queries
If you have a Business or Enterprise plan, you will also have access to a call that allows you to query your tables. This option is not available to Glide users with the Pro plan.
The queryTables
call takes a list of table names and returns all the rows in those tables.
It takes a JSON body of the following form:
1. {
2. "appID": "jD5sfkQujM9ywabItn0l",
3. "queries": [QUERY, ...]
5. }
Each query looks like this:
1. {
2. "tableName": "TABLE-NAME",
3. "startAt": CONTINUATION
5. }
startAt
is optional, and needs only be sent when continuing a previous query that did not return all rows. For example:
The call returns an array with one element for each query, each of which looks like this:
1. {
2. "rows": [ROW, ...],
3. "next": CONTINUATION
5. }
Each row
is a row object, with one property per column. The next
field will only be sent when there are more rows in the table than Glide sent in the response. To get more rows, make another call and send the CONTINUATION
in startAt
.
Filtered Queries with Big Tables
If you have a Business or Enterprise plan, you will also have access to a call that allows you to query your Big Tables with SQL type statements. This option is not available to Glide users with the Pro plan, nor does it work with regular Glide Tables.
When querying a Big Table with SQL, a query looks like this:
{
"sql": "SELECT * FROM ...",
"params": [PARAM1, PARAM2, ...]
}
The params
array is optional, but it must be given if the SQL query refers to any parameters.
The allowed SQL is a small strict subset of ANSI SQL. The restrictions are:
- All columns must be selected via
*
, nothing else can be used - Only one table can be queried
- No joins or sub-queries
- No group-by
ORDER BY
only allows sorting by a single column- The
WHERE
clause allows conditions combined withAND
, as well asOR
.OR
s can be nested withinAND
s, but not the other way around. - Only a few conditions are allowed:
- Checking for equality with
=
, or comparisons with<
,>
,<=
,>=
, between a column and a constant, or a column and a column - Checking whether a column is (not) empty with
IS [NOT] NULL
- Checking for equality with
LIMIT
is supported, but the API will not return more than 1000 rows
Query parameters
The preferred way for the query to include constant values is via parameters, to avoid having to escape strings and format numbers. These are written as numbers, starting at 1
, preceded by a dollar sign, i.e. $1
, $2
, ... If the query uses parameters then they must be passed in the params
array. $1
refers to the first element in that array, $2
to the second, and so on. Parameters can be strings, numbers, and booleans, as well as date-times formatted as strings like 1992-01-01T12:18:25.040Z
.
Other considerations
- The table name for
FROM
has to be the same table name that would otherwise be passed astableName
- The column names are the same as used with the regular API
- Continuations (
startAt
) are not yet supported
Example
Let's say we want to query a table for which the curl
command for Add rows
is this:
curl --request POST 'https://api.glideapp.io/api/function/queryTables' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer **********' \
--data-raw '{
"appID": "i9nkuGit0hSil4z6GzEn",
"mutations": [
{
"kind": "add-row-to-table",
"tableName": "native-table-ae5c9f4b-a2be-4fdf-bc9a-27db74c3aaa0",
"columnValues": {
"Name": "Name",
"Material": "Material",
"Category": "Category",
"Image": "Image",
"Price": "Price",
"ID": "ID",
"CompanyID": "CompanyID"
}
}
]
}'
We want to get the first 10 rows from that table where
Name
isRecycled Soft Hat
andMaterial
isWooden
orCategory
isShoes
The query we would send to queryTables
in that case would be
{
"sql": "SELECT * FROM \"native-table-ae5c9f4b-a2be-4fdf-bc9a-27db74c3aaa0\" WHERE \"Name\" = $1 AND (\"Material\" = $2 OR \"Category\" = $3) LIMIT 10",
"params": ["Recycled Soft Hat", "Wooden", "Shoes"]
}
Note that we have to quote the column names in SQL so they're interpreted case-sensitively.
The full curl
command would be
curl --request POST 'https://api.glideapp.io/api/function/queryTables' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer **********' \
--data-raw '{
"appID": "i9nkuGit0hSil4z6GzEn",
"queries": [
{
"sql": "SELECT * FROM \"native-table-ae5c9f4b-a2be-4fdf-bc9a-27db74c3aaa0\" WHERE \"Name\" = $1 AND (\"Material\" = $2 OR \"Category\" = $3) LIMIT 10",
"params": ["Recycled Soft Hat", "Wooden", "Shoes"]
}
]
}'
Learn Glide Tables API
Want to see the API in action? Explore the resources below.