Write Data in Real Time with POST /record#
You can call the POST /record endpoint to write small amounts of data (i.e., one or a few records per call) and to publish events to Rules Engine in real time.
Here we’ll store a record to Apperate and query the stored data.
Note
POST /record doesn’t guarantee the ordering of records.
POST /record doesn’t write to any logs. If records fail validation, consider loading the records instead. After attempting to load records, you can view invalid records. See the instructions at Troubleshoot Invalid Data Records.
Prerequisite
IEX Cloud Apperate account - Create one here.
Call POST /record#
Prepare a
POST /record
endpoint call. For example, use the following cURL command, replacing theWORKSPACE
,DATASET_ID
, andSECRET_TOKEN
values with your workspace name, a target dataset, and your secret API token and replacing the data (the single-quoted array following-d
) with your own JavaScript object array.curl -X POST https://WORKSPACE.iex.cloud/v1/record/WORKSPACE/DATASET_ID?token=SECRET_TOKEN \ -H 'Content-Type: application/json' \ -d '[{"headline": "Are Hovercrafts the next big thing?", "content": "Here is what people are saying ...", "ticker": "GM", "source": "IEX Underground", "date": "2022-07-15"}]'
Execute the command.
The method returns a response like the one below and writes the data to the target dataset.
{"success":true,"message":"wrote 1 messages"}
View the Data#
In the Console under Datasets, click on your workspace name.
Your workspace datasets page appears. It includes the target dataset from your
POST /record
call.Click on the target dataset name. The dataset’s Database page appears and lists the dataset records.
Note
On auto-generating a dataset, Apperate infers a schema from your data; you can update the schema via the schema editor (click Edit to open the editor).
Query the Data#
Click on the Overview tab. The dataset’s overview page appears.
Click on the Example Request. A browser tab opens and the query response includes the record you posted.
[ { "content": "Here is what people are saying ...", "date": "2022-07-15", "headline": "Are Hovercrafts the next big thing?", "source": "IEX Underground", "ticker": "GM" } ]
The example request called the
GET /data
endpoint to get the last record.See also
See Query Data for all the ways to query Apperate’s real-time data store.
Congratulations! You stored data using the POST /record
endpoint and queried it.
What’s Next#
Write Data with the apperate.write() JS Method demonstrates the easiest way to store data in JavaScript environments. Note apperate.write()
wraps POST /record
.
Real-Time Write Performance Tips helps you optimize data writes for your use cases.
Filter on Custom Dataset Events guides you in configuring alerts on important incoming data events.
Update a Dataset Schema shows how to examine and modify your dataset schema.