Download OpenAPI specification:Download
HTTP API to sync partial replicas of your Postgres data into local apps and services.
See the Electric documentation for more information.
Load the initial data for a shape and poll for real-time updates.
Define your shape using the table
and where
parameters.
Use offset
to fetch data from a specific position in the shape
log and the live
parameter to consume real-time updates.
table required | string Examples:
Root table of the shape. Must match a table in your Postgres database. Can be just a tablename, or can be prefixed by the database schema
using a |
offset required | string Examples:
The offset in the shape stream. This is like a cursor that specifies the position in the shape log to request data from. When making an initial request to sync a shape from scratch, you
must set the Alternatively, you can set Note that when |
live | boolean Whether to wait for live updates or not. When the Once you're up-to-date, you should set the This allows you to implement a long-polling strategy to consume real-time updates. |
cursor | string This is a cursor generated by the server during live requests. It helps bust caches for responses from previous long-polls. |
handle | string Example: handle=3833821-1721812114261 The shape handle returned by the initial shape request. This is a required parameter when this is not an initial sync request,
i.e. when offset is not |
where | string Examples:
Optional where clause to filter rows in the This should be a valid PostgreSQL WHERE clause using SQL syntax. For more details on what is supported and what is optimal, see the where clause documentation. If this where clause uses a positional parameter, it's value must be provided under |
object Examples:
Optional params to replace inside the where clause. Uses an "exploded object" syntax (see examples). These values will be safely interpolated inside the where clause, so you don't need to worry about escaping user input when building a where clause. If where clause mentions a posisional parameter, it becomes required to provide it. | |
columns | string Examples:
Optional list of columns to include in the rows from the They should always include the primary key columns, and should be formed as a comma separated list of column names exactly as they are in the database schema. If the identifier was defined as case sensitive and/or with special characters, then |
replica | string Enum: "default" "full" Modifies the data sent in update and delete change messages. When When set to Note that insert operations always include the full row, in either mode. |
log | string Default: "full" Enum: "full" "changes_only" Examples:
Controls the initial data loading mode for the shape. When When
In |
subset__where | string Examples:
Optional WHERE clause to filter a subset of the shape data. Presence of this or other This allows you to fetch a specific portion of the shape's data with additional filtering beyond the main shape's WHERE clause. This filter is always applied in addition to the main shape's WHERE clause, so it's not possible to get data that doesn't match the main shape's WHERE clause. |
object Parameters for the subset WHERE clause. Uses the same "exploded object"
syntax as the main Presence of this or other | |
subset__limit | integer >= 1 Examples:
Maximum number of rows to return in the subset snapshot. Presence of this or other When |
subset__offset | integer >= 0 Examples:
Number of rows to skip in the subset snapshot (for pagination). Presence of this or other When |
subset__order_by | string Examples:
ORDER BY clause for the subset snapshot, determining the row ordering. Uses
same syntax as Presence of this or other This becomes required when using |
secret | string Example: secret=1U6ItbhoQb4kGUU5wXBLbxvNf Secret defined by the ELECTRIC_SECRET
configuration variable. This is required unless
|
api_secret | string Deprecated Example: api_secret=1U6ItbhoQb4kGUU5wXBLbxvNf Deprecated in favor of the |
If-None-Match | string Re-validate the shape if the etag doesn't match. |
[- {
- "headers": {
- "operation": "insert",
- "lsn": 1234,
- "op_position": 0
}, - "key": "issue-1",
- "value": {
- "id": "issue-1",
- "title": "Electric",
- "status": "backlog"
}
}, - {
- "headers": {
- "operation": "insert",
- "lsn": 1234,
- "op_position": 7
}, - "key": "issue-2",
- "value": {
- "id": "issue-2",
- "title": "Hello",
- "status": "backlog"
}
}, - {
- "headers": {
- "control": "up-to-date"
}
}
]
Deletes the shape from the Electric sync engine.
This clears the shape log and forces any clients requesting the shape to create a new shape and resync from scratch.
NOTE Delete shape only works if Electric is configured to allow_shape_deletion
.
table required | string Examples:
The name of the table for which to delete the shape. Can be qualified by the schema name. |
source_id | string The ID of the database from which to delete the shape. This is required only if Electric manages several databases. |
handle | string Example: handle=3833821-1721812114261 Optional, deletes the current shape if it matches the |
secret | string Example: secret=1U6ItbhoQb4kGUU5wXBLbxvNf Secret defined by the ELECTRIC_SECRET
configuration variable. This is required unless
|
api_secret | string Deprecated Example: api_secret=1U6ItbhoQb4kGUU5wXBLbxvNf Deprecated in favor of the |