Webhooks

Webhooks make it easy for algorithmic traders to integrate notifications into their automated trading systems. Rather than receiving an alert via SMS or email, TrendSpider can be configured to send an HTTP POST request to any URL.

It’s easy to get started using web hooks:

  1. Click on the User Icon in the upper-right corner of the screen.
  2. Select Account & Settings.
  3. Check the Webhook box under Email and SMS.
  4. Input the URL where POST requests should be sent.

Webhooks

Webhooks send a POST request with a body equal to each alert’s description. If the description contains valid JSON, the content-type header is set to "application/json", otherwise it’s set to "text/plain". The Alert dialog will display “valid JSON” below the description field if the field contains valid JSON.

Webhooks

The Webhook supports the following variables in descriptions:

  • %alert_name% returns the name of the alert.
  • %alert_symbol% returns the symbol.
  • %alert_note% returns the notes for the alert.
  • %price_action_event% returns one of: touch, break_through, bounce, script_returned_true.
  • %last_price% returns the price of an asset for the moment when the alert has fired.

An example POST request might look like this:

HTTP POST https://webhook.site/1902dc91-ffdb-4322-9c65-5df94cec5f34?symbol=AAPL
Content-Type: application/json
X-requester: trendspider
X-reason: alert-webhook

{"event":"alert_triggered","which":"Alert Name","other_param":42}

The requests timeout after five seconds. All Webhooks are sent from a specific host with the IP address 3.12.143.24, which can be whitelisted to maximize reliability.

Example: Deliver Alerts to Discord

In your Notification settings on TrendSpider, paste the URL of the webhook (the one which Discord gives you, it usually looks like "https://discord.com/api/webhooks/111....10/9Na....e87a" — these lengthy parts would be different, but the overall look would be similar).

According to Discord's documentation, they need your webhook receiving something like "{"content": "Look ma, my webhook just worked"}". Paste that into your alert's "Description" or "Your Note" input on TrendSpider.

Wait for your alert to fire and confirm that you've got a message delivered to your Discord.

After that, you can customize your alert message suing variables listed above. E.g., "{"content": "Alert triggered: %alert_name% on %alert_symbol%, %price_action_event%"}".

Feb 25, 2021