Data APIs Quickstart¶
This walkthrough uses both Data APIs in one round trip: you create a table, insert a row over the REST API, and watch it arrive live over a WebSocket subscription. It takes a few minutes and assumes an AmiCore process with a running Center named center.
1. Enable both surfaces¶
In local.properties:
Restart the process. Confirm the WebSocket started (log line):
2. Create a table to stream¶
A table that REST and WebSocket clients can share must be a CREATE PUBLIC TABLE: that is what makes it shared. Public tables broadcast by default, so they stream without further options; Broadcast="true" below only states the default. Create the QUOTES table over REST (substitute your host and Web port; -k accepts a self-signed dev certificate):
Then give it a primary key. The key is a separate CREATE INDEX statement: there is no primary-key clause inside CREATE TABLE:
Both return "status":"ok", and SHOW TABLES now reports QUOTES with Broadcast:true, Scope:PUBLIC.
Use CREATE PUBLIC TABLE, not CREATE TABLE
A plain CREATE TABLE returns "status":"ok" but the table is transient: a later stateless REST call or a WebSocket watcher gets Unknown table. Only a PUBLIC table is shared live state these APIs can see and subscribe to, and only a PUBLIC table accepts USE options. CREATE REALTIME TABLE and a PRIMARYKEY clause inside CREATE TABLE are not valid syntax. See Concepts → Creating a streamable table.
3. Insert the first row over REST¶
The response reports "rowsAffected":1.
Rows don't survive a restart
This QUOTES table has no PersistEngine, so its rows are lost if the process restarts (the empty table definition remains). That's fine for the quickstart; for data that must persist, see Concepts → Creating a streamable table.
4. Subscribe over WebSocket¶
Open the reference client that ships with AmiCore (reference-client.html) in a browser, or use the minimal client below. Set the URL to ws://localhost:3410/center and subscribe to QUOTES:
You should see these frames. The first 2 can arrive in either order:
The initial row arrives as an add, and the snapshot frame follows it to mark the end of the initial load: your client now holds the current table. See WebSocket API → First messages on connect.
5. Write again, watch it stream¶
With the subscription still open, update the row over REST:
Within about 100 ms (the conflation flush interval) your WebSocket client receives an updates frame with an update action for the IBM row, carrying only the changed fields:
Match it to the earlier add by its objectId (an internal row id, not the SYM). Insert a second symbol and an add arrives the same way.
That is the whole model: REST writes, WebSocket watches.
6. Clean up¶
Where to go next¶
- REST API: every
/queryparameter and response format. - WebSocket streaming API: the full frame protocol, conflation, and focus filtering.
- Use cases: worked examples for querying, writing, and streaming.