# API

This API  enables users to automate trading strategies by crafting **custom signals** that respond to specific market conditions. This allows seamless integration with tools like TradingView or custom scripts in Python and other languages.

Custom Signals function similarly to TradingView webhooks—triggering trading rules based on external inputs. You have full flexibility to connect any signal-generating system to Coinrule via webhook.

## Understand the Signal API

Explore the `/signal` endpoint and its related data models to understand how to format and send your custom trading signals correctly:

* [**`/signal` Endpoint**](https://coinrulehq.gitbook.io/docs/api/custom-rule-signal)\
  This single endpoint receives your trading signals. It accepts a JSON payload defined by the payload schema.
* [**Data Schemas**](https://coinrulehq.gitbook.io/docs/api/models)\
  These models describe the structure of signals and related data:
  1. **Payload Schema** – defines fields like `signal`, `symbol`, and any additional metadata.
  2. **Response Schema** – outlines what Coinrule returns after signal ingestion.
  3. **Error Schema** – details formats for error responses if your signal is invalid or malformed.

## Getting Started

Use the following steps to implement your custom signal and start automating trades:

1. **Create a new rule** in [Coinrule](https://web.coinrule.com/), see the example below for TradingView signals (change this to "Custom Signal" for other integrations).

   <figure><img src="https://1988282696-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE8u64Pc6KYKhPQ1oufpt%2Fuploads%2FeGn1NWxFpgiK0BdPQ2zm%2Fimage.png?alt=media&#x26;token=ee67f979-e0d4-4e69-ab26-d348b8c2f4bf" alt=""><figcaption></figcaption></figure>
2. After setup, click **Launch** to activate the rule.
   * **Custom Signals:** Each rule will generate a unique webhook URL. Send your custom signal to this endpoint to trigger the rule.
   * **TradingView SIgnals:** After clicking, '**Launch**' a pop-up opens with settings for TradingView - this provides the Webhook URL and Message. Do not launch the rule again yet as we need to copy and paste these details when creating the TradingView alert.&#x20;
3. **Configure Your Signal Source:** TradingView alerts, Python scripts, any external script that sends HTTP requests.
4. If your rule supports both **BUY** and **SELL**, your message should include an `"ACTION"` placeholder. Your script must replace it with `"buy"` or `"sell"` depending on the condition.
5. Select from a variety of programming languages to match your development preferences:
   * cURL
   * Python
   * JavaScript

## Step-by-Step Guides

For a complete setup walkthrough, refer to the following official guides:

* [🔗 How to Create Rules Using TradingView Signals on Coinrule](https://atlas-kb.com/atlas-sbw870763c/articles/595838-how-to-create-rules-using-tradingview-signals-on-coinrule)\
  \&#xNAN;*A comprehensive guide covering rule creation and alert setup using TradingView.*
* [🔗 Using Custom Signals on Coinrule](https://help.coinrule.com/articles/151602-using-custom-signals-on-coinrule)\
  \&#xNAN;*Learn how Custom Signals work and how to send them from any source.*
* [🔗 How TradingView Triggers Coinrule’s Actions](https://help.coinrule.com/articles/120887-how-tradingview-triggers-coinrule-s-actions)\
  \&#xNAN;*Deep dive into how TradingView alerts are parsed and used by Coinrule to trigger trades.*

Watch the tutorial video for a hands-on demonstration of the TradingView signal integration process:

{% embed url="<https://www.youtube.com/watch?v=KaasD2vGDRU>" %}

&#x20;

For additional help, visit our [Help Center](https://help.coinrule.com) or the [Open API Specification.](https://api.coinrule.com/v2/#/)
