Pushing Financial Notifications to Apps via Rule Webhooks#
DEPRECATED
Apperate and its features (including this feature) are deprecated.
You can create Rules to push real-time IEX Cloud Financial Data events to your apps via webhooks. Apperate delivers events to your app as they happen! Why poll for events when Apperate rules can push events to your apps automatically? Here we’ll show you how to set it up.
Overview:
Create a webhook address in your app.
Create a rule to push the events you want.
Examine the event payload.
Use the payload.
Requirements
An Apperate account. Start your Free Trial.
An Apperate workspace. Create a workspace.
Note
This tutorial uses JavaScript, but you can apply these concepts in setting up an Apperate push event flow for apps that use other languages.
Let’s get started.
Step 1: Create a Webhook Address in Your App#
Your app needs a REST endpoint to receive push events. It’s a standard REST endpoint for handling HTTP POST requests. The endpoint path is arbitrary. For example, the Node JS Express function below creates a POST endpoint at <your-domain>/price-alerts
.
app.post("/price-alerts", (req, res) => {
console.log('Received webhook event: ', req.body);
// Handle the webhook payload contained in the request body here
res.status(200).end();
});
For demonstration purposes, the function above simply logs a message that includes the request body (i.e., the event payload).
Next we’ll create an Apperate rule that pushes events to the webhook address (e.g., <your-domain>/price-alerts
).
Tip
Optionally, you can configure a webhook address in a site like Webhook.site and send events there to get familiar with them before sending them to your app.
Step 2: Create a Rule to Push the Events You Want#
It’s time to create a rule to push the events you want to your app.
Here are some ways to start creating a rule:
For this example, we’ll use the first option and modify a copy of the Apple Price Alert example rule.
Note
Create a workspace if you haven’t already created one for your account.
In the console Home, go to the box titled Apple Price Alert and click its Create Rule button.
Apperate copies the rule and opens the Rule Wizard for you to modify the copy.
Modify the triggering condition(s) to whatever you want. For more details on setting conditions, see Set Your Conditions. Advance to the outputs page when you’re done with the conditions.
In the outputs page’s Alert Details section, set the rule to output to your webhook.
Select Alert Type → Webhook.
For Webhook URL, specify your app’s webhook address (i.e., your app’s endpoint URL).
Set the Wait time between alerts to the frequency you want to receive event notifications.
Optionally, specify any Additional Indexes (facts) to include in the event payload. Note, condition indexes are included automatically.
When you’re done with outputs setup, advance to the summary page.
On the summary page, review your rule and name it. If you need to modify conditions or outputs, go back to those pages, make your changes, and then return to the summary page. When you’re ready to launch your rule, click Create Rule.
Apperate activates your rule and displays it in the Rules Dashboard.
Click on your rule’s name to see live details.
Now that events are flowing, let’s examine the event payload.
Step 3: Examine the Event Payload#
View the event payloads received at your endpoint. For example, here’s a sample payload from the above rule.
{
"data": {
"id": "53dbccf6-38ab-4909-b910-c1c97daf6d0f",
"name": "Apple price alert",
"ruleEvent": {
"CORE:STOCK:AAPL:iexLastSalePrice": 176.35
},
"timestamp": 1694550560703
}
}
The payload includes the rule condition index: CORE:STOCK:AAPL:iexLastSalePrice
is $176.35
. The table below defines the payload fields.
Payload Fields#
Field |
Description |
---|---|
|
Apperate-generated unique Rule identifier. |
|
The rule’s name. |
|
A set of name/value pairs representing the rule indexes (the condition fact indexes and output indexes) at the time of the event. |
|
The time the event occurred (in Epoch seconds). |
Step 4: Use the Payload#
Now that you have the event payload, you can persist, derive the data you want from it, and render the data in your UI. It’s simply up to you.
Conclusion#
Now you know how to push real-time IEX Cloud Financial Data events to your apps. Stay tuned for additional push event resources landing in Apperate Guides and the IEX Cloud YouTube channel. Happy eventing!
Additional Resources#
Here are some more resources for working with IEX Cloud Financial Data events.
Creating Rules Using the API demonstrates creating and managing rules programatically.
Event processing articles in Apperate Guides cover everything you need for deploying push events and more. They cover sending IEX Cloud Financial Data events and custom data events, configuring event destinations including email, Slack, custom datasets, and managing event rules.