Skip to content

Collection of code examples demonstrating how to interact with a Psyll webhook endpoint using various programming languages

License

Notifications You must be signed in to change notification settings

ablemaster025/Webhook-Examples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt text

Webhook Examples

This repository provides a collection of code examples demonstrating how to interact with a Psyll webhook endpoint using various programming languages. Each example performs a POST request to the webhook with a payload to execute a trading action, such as a "BUY" order for BTCUSDT. The examples are designed to be simple, reusable, and adaptable for various use cases, enabling developers to integrate trading functionality into their applications.

What is webhook?

Webhook enable executing trades across exchanges through simple HTTP POST requests. They are ideal for automating complex trading strategies, allowing bot developers to seamlessly integrate trading logic, respond instantly to alerts, and embed trading functionality into any backend system for complete automation.

Create a webhook on Psyll.com

  1. Navigate to Psyll.com website
  2. Login to your user account
  3. Navigate to "My Webhooks" under the user menu (top-right corner)

alt text

  1. Click "Create new webook"

alt text

  1. Complete the form by providing:

alt text

  • A unique webhook name.
  • The exchange you wish to connect to.
  • Valid API keys for the selected exchange.

Limits

Account type Number of webhooks Daily limits
Free account 1 10 requests
PRO account 15 100 requests

Webhook request

Request URL:

https://psyll.com/env/webhook/{WEBHOOK-ID}

Replace {WEBHOOK-ID} with the unique identifier provided when you created the webhook.

Request data

{
  "code": "{WEBHOOK-CODE}",
  "action": "{ACTION}",
  "quantity": "{QUANTITY}",
  "symbol": "{SYMBOL}"
}

Data descriptions

Name Type Description
code string unique authentication code required to validate the webhook request, ensuring secure access to the API.
action string Specifies the trading action to be performed. Allowed Values: BUY, SELL, SET
quantity float Defines the amount of the asset to trade
symbol string Identifies the trading pair or asset for the order. The symbol must match a valid trading pair supported by the exchange

Webhook response

A successful webhook request returns a JSON response with the following structure:

{
    "created": "2025-07-07 18:25:20",
    "limit": {
        "account": "PRO",
        "max_per_day": 200,
        "usage": 3
    },
    "message": "Order placed",
    "request": {
        "action": "SET",
        "code": "{WEBHOOK-CODE}",
        "quantity": "1",
        "symbol": "BTCUSDC"
    },
    "status": "success",
    "response": {
        ... Exchange response
    }
}

Response Fields

Field Description
created Timestamp indicating when the request was processed.
limit Object containing account tier, daily request limit, and current usage.
message A brief description of the request outcome.
request Echoes the submitted request data for verification.
response The results of exchange operation. This could include confirmation of a trade order, its ID, execution status, or other data.
status Indicates the outcome of the request, e.g., "success" or "error".

Error Handling

If a request fails, the response will include an error status and a descriptive message. Example:

{
    "created": "2025-07-07 18:37:08",
    "limit": {
        "account": "PRO",
        "max_per_day": 200,
        "usage": 4
    },
    "message": "Account has insufficient balance for requested action.",
    "request": {
        "action": "SET",
        "code": "{WEBHOOK-CODE}",
        "quantity": "1",
        "symbol": "BTCUSDC"
    },
    "status": "error"
}

Ensure that the code, action, quantity, and symbol fields are valid to avoid errors.

Common Issues

  • Incorrect or missing webhook code: Ensure the code field matches the webhook code provided by Psyll.
  • Unsupported trading pair: Verify that the symbol is valid for the selected exchange.
  • Invalid quantity format: Use a representation of a numeric value (e.g., "1.5") to maintain precision.
  • Rate limit exceeded: Check the limit field in the response to monitor usage against the daily limit.

Getting Started

  1. Clone this repository to your local machine:
git clone https://github.com/username/webhook-examples.git
  1. Navigate to the directory of the desired programming language.
  2. Update the WEBHOOK_URL and WEBHOOK_CODE variables with your webhook ID and code.
  3. Install any required dependencies (e.g., requests for Python, axios for Node.js).
  4. Run the example script to test the webhook request.

Programming languages

The repository includes example implementations in the following programming languages:

Name Folder
Python Python View files
C# C# View files
PHP PHP View files
JavaScript JavaScript View files
NodeJS NodeJS View files
Go Go View files
Java Java View files
Kotlin Kotlin View files
Ruby Ruby View files
Rust Rust View files
Swift Swift View files
TypeScript TypeScript View files

Security Best Practices

  • Secure Webhook Code: Store WEBHOOK_CODE in environment variables or a secure configuration file, not in source code.
  • Validate Responses: Always check the status field in the response to confirm the request outcome.
  • Monitor Rate Limits: Use the limit field to track daily usage and avoid exceeding quotas.
  • Use HTTPS: Ensure all requests are sent over HTTPS to protect sensitive data.

Troubleshooting

  • Connection Errors: Verify that WEBHOOK_URL is correct and accessible.
  • Invalid Payload: Double-check the format and values of code, action, quantity, and symbol.
  • Authentication Issues: Confirm that the WEBHOOK_CODE matches the code provided by Psyll.
  • Exchange-Specific Errors: Ensure the selected exchange supports the specified symbol and that your API keys have the necessary permissions.

Additional Resources

Contributing

Contributions are welcome ❤️ To contribute:

  1. Fork the repository.
  2. Create a new branch for your changes git checkout -b feature/new-example)`.
  3. Commit your changes with a clear message git commit -m "Add example for <language>")`.
  4. Submit a pull request with a detailed description of your changes.

Please ensure your code adheres to the repository's style guidelines and includes appropriate documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Collection of code examples demonstrating how to interact with a Psyll webhook endpoint using various programming languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 19.5%
  • JavaScript 11.4%
  • Swift 10.7%
  • C# 9.7%
  • Kotlin 9.5%
  • Go 9.4%
  • Other 29.8%