Popular topics: Community Guidelines, Cookie Policy

Webhook Integration Documentation for Third-Party Servers

Overview 

This documentation provides the details for integrating with the webhook feature provided by BitChute. This webhook feature allows BitChute’s server to send data (via HTTP requests) to your server when certain events occur. The data will either be sent via GET or POST requests, and may include an API key for authentication. 

The following sections explain how to configure your server to handle incoming webhook requests, manage the API key, and handle payload data. 

 

1. Webhook Request Options 

1.1. Request Methods 

The webhook requests can be sent using either of the following HTTP methods: 

GET: Data is sent as query parameters in the URL. 

POST: Data is sent in the request body, typically as JSON. 

GET Request 

When the webhook is configured to use the GET method, data will be included in the URL as query parameters. This method is best suited for simple and small data transmission. 

Example GET Request: 

GET https://your-server.com/webhook?name=JohnDoe&age=30 

 

POST Request 

When the webhook is configured to use the POST method, data will be sent in the request body in JSON format. 

Example POST Request: 

POST https://your-server.com/webhook 
Content-Type: application/json 
 
{ 
  "name": "John", 
  "amount": 100, 
  "currency": "usd", 
  "message": "Hello", 
  "datetime": "2025-01-21 06:57:02.823449+00:00" 
} 
 

 

1.2. API Key Authentication 

To authenticate webhook requests, BitChute may include an API key in the request headers or as a query parameter. This key is used to verify that the request is coming from an authorized source. 

API Key in the Headers 

The API key is commonly sent in the X-API-Key header: 

Authorization: Bearer YOUR_API_KEY 

X-API-Key: YOUR_API_KEY 
X-Auth-Token: YOUR_API_KEY 
x-access-token: YOUR_API_KEY 
 

 

1.3. Hashing the API Key (Optional) 

To enhance the security of the API key and request data, [Your Company Name] provides an option to hash the API key along with the request payload. This hash can be used by your server to verify the integrity of the request. 

How to Generate and Verify the Hashed API Key 

When hashing is enabled, BitChute’s server will: 

Sort the JSON payload by keys. 

Convert the sorted JSON to query parameters. 

append a secret key to the query parameters. 

Generate a hash of the resulting string (using SHA-256). 

Send the resulting hash in the X-API-Key header. 

Your server can use the following Python function to recreate the hash for verification. 

Example Python Function for Generating the Hash 

import hashlib 
import urllib.parse 
 
def json_to_hashed_query_params(data, secret_key=None): 
    """ 
    Hashes a JSON payload converted to sorted query parameters. 
 
    :param data: The JSON payload as a dictionary. 
    :param secret_key: Optional secret key to include in the hash. 
    :return: The hashed value as a hex string. 
    """ 
    # Sort JSON keys to ensure consistent order 
    sorted_data = {key: data[key] for key in sorted(data)} 
 
    # Convert sorted JSON to query parameters 
    query_params = urllib.parse.urlencode(sorted_data) 
 
    # Optionally add a secret key 
    if secret_key: 
        query_params += f"&key={secret_key}" 
 
    # Hash the query parameters 
    hashed = hashlib.sha256(query_params.encode('utf-8')).hexdigest() 
    return hashed 
 

 

Example Workflow: 

From the Webhook Request: 

Assume the incoming request has the following payload: 

{ 
  "name": "John", 
  "amount": 100, 
  "currency": "usd", 
  "message": "Hello", 
  "datetime": "2025-01-21 06:57:02.823449+00:00" 
} 
 

The X-API-Key header contains the hash: 

X-API-Key: <hashed_value> 
 

On Your Server: 

Use the same payload, along with your stored secret key, to generate the hash using the json_to_hashed_query_params function. 

Compare the resulting hash with the value in the X-API-Key header. 

Verification Example: 

# Incoming payload and hashed key 
incoming_payload = {"name": "JohnDoe", "age": 30, "event": "signup"} 
incoming_hashed_key = "<hashed_value>"  # From X-API-Key header 
 
# Your stored secret key 
secret_key = "YOUR_SECRET_KEY" 
 
# Recreate the hash 
calculated_hashed_key = json_to_hashed_query_params(incoming_payload, secret_key) 
 
# Compare hashes 
if incoming_hashed_key == calculated_hashed_key: 
    print("Request is authenticated") 
else: 
    print("Request is invalid") 
 

 

2. Webhook Payload Format 

2.1. GET Request Payload 

When a GET request is sent, the data will be included in the URL as query parameters. For example, a GET request might look like this: 

GET https://your-server.com/webhook?name=John&amount=100&currency=usd&message=Hello&datetime= 2025-01-21 06:57:02.823449+00:00 
 

2.2. POST Request Payload 

When a POST request is sent, the data will be sent in the request body, typically in JSON format. Here is an example of the POST request payload:  https://www.bitchute.com/communication 

Was this article helpful?

Can’t find what you’re looking for?

Our customer support team is here for you.

Contact Support

BitChute is a peer-to-peer content sharing platform. Creators are allowed to post content they produce to the platform, so long as they comply with our policies. The content posted to the platform is not reflective or representative of the views of BitChute, its staff or owners. BitChute and all associated trademarks are owned and operated by Deep State Protocol LLC. © 2017-2024 DSP LLC.


Knowledge Base Software powered by Helpjuice