Create Webhook
curl --request POST \
--url https://api.chainbase.online/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"webhook_name": "<string>",
"webhook_url": "<string>",
"data_source": "<string>",
"filters": [
{
"field": "<string>",
"values": []
}
],
"additional_headers": [
{
"name": "<string>",
"value": "<string>"
}
]
}
'import requests
url = "https://api.chainbase.online/v1/webhooks"
payload = {
"webhook_name": "<string>",
"webhook_url": "<string>",
"data_source": "<string>",
"filters": [
{
"field": "<string>",
"values": []
}
],
"additional_headers": [
{
"name": "<string>",
"value": "<string>"
}
]
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_name: '<string>',
webhook_url: '<string>',
data_source: '<string>',
filters: [{field: '<string>', values: []}],
additional_headers: [{name: '<string>', value: '<string>'}]
})
};
fetch('https://api.chainbase.online/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chainbase.online/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'webhook_name' => '<string>',
'webhook_url' => '<string>',
'data_source' => '<string>',
'filters' => [
[
'field' => '<string>',
'values' => [
]
]
],
'additional_headers' => [
[
'name' => '<string>',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.chainbase.online/v1/webhooks"
payload := strings.NewReader("{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chainbase.online/v1/webhooks")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chainbase.online/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"{\"code\":0,\"msg\":\"create job success\",\"data\":{\"webhook_id\":\"460009d1-f7ce-43a9-9747-681054ffb462\",\"filters\":[{\"field\":\"contract_address\",\"values\":[\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599\",\"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\"0xdAC17F958D2ee523a2206206994597C13D831ec7\"]}],\"webhook_name\":\"massive-erc20-transfer\",\"webhook_url\":\"https://gtsfh5g3c4.hk.aircode.run/erc20transfer\",\"data_source\":\"ethereum_erc20_transfer\",\"additional_headers\":[{\"name\":\"Authorization\",\"value\":\"Bearer xyz\"}],\"created_at\":\"2023-08-23T03:27:28.281175Z\",\"updated_at\":\"2023-08-23T03:27:28.281175Z\",\"status\":0}}""{\"code\":-1,\"msg\":\"auth verify-secret-key error\",\"data\":null}"Create Webhook
Create webhook to receive message.
POST
/
webhooks
Create Webhook
curl --request POST \
--url https://api.chainbase.online/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"webhook_name": "<string>",
"webhook_url": "<string>",
"data_source": "<string>",
"filters": [
{
"field": "<string>",
"values": []
}
],
"additional_headers": [
{
"name": "<string>",
"value": "<string>"
}
]
}
'import requests
url = "https://api.chainbase.online/v1/webhooks"
payload = {
"webhook_name": "<string>",
"webhook_url": "<string>",
"data_source": "<string>",
"filters": [
{
"field": "<string>",
"values": []
}
],
"additional_headers": [
{
"name": "<string>",
"value": "<string>"
}
]
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_name: '<string>',
webhook_url: '<string>',
data_source: '<string>',
filters: [{field: '<string>', values: []}],
additional_headers: [{name: '<string>', value: '<string>'}]
})
};
fetch('https://api.chainbase.online/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chainbase.online/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'webhook_name' => '<string>',
'webhook_url' => '<string>',
'data_source' => '<string>',
'filters' => [
[
'field' => '<string>',
'values' => [
]
]
],
'additional_headers' => [
[
'name' => '<string>',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.chainbase.online/v1/webhooks"
payload := strings.NewReader("{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chainbase.online/v1/webhooks")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chainbase.online/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_name\": \"<string>\",\n \"webhook_url\": \"<string>\",\n \"data_source\": \"<string>\",\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"values\": []\n }\n ],\n \"additional_headers\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"{\"code\":0,\"msg\":\"create job success\",\"data\":{\"webhook_id\":\"460009d1-f7ce-43a9-9747-681054ffb462\",\"filters\":[{\"field\":\"contract_address\",\"values\":[\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599\",\"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\"0xdAC17F958D2ee523a2206206994597C13D831ec7\"]}],\"webhook_name\":\"massive-erc20-transfer\",\"webhook_url\":\"https://gtsfh5g3c4.hk.aircode.run/erc20transfer\",\"data_source\":\"ethereum_erc20_transfer\",\"additional_headers\":[{\"name\":\"Authorization\",\"value\":\"Bearer xyz\"}],\"created_at\":\"2023-08-23T03:27:28.281175Z\",\"updated_at\":\"2023-08-23T03:27:28.281175Z\",\"status\":0}}""{\"code\":-1,\"msg\":\"auth verify-secret-key error\",\"data\":null}"Headers
YOUR-API-KEY
Example:
"demo"
Body
application/json
Name of the webhook
URL of the webhook
Data source the webhook subscribe to
Filter Object
Show child attributes
Show child attributes
Additional headers would be added into the webhook POST when push message is matched.
Show child attributes
Show child attributes