Create subscriptions
If you are using JavaScript, the Ocelloids Client Library offers a more convinient way to interact with the services.
You can easily subscribe to the logic bundled within an agent using any HTTP client.
In these examples, we will use curl as the HTTP client.
To create a subscription, send a POST request to the /subs
endpoint with the appropriate authorization header.
Example Request
This example request subscribes to the General Informant agent to deliver notifications to your webhook endpoint.
Please, replace <YOUR_API_KEY>
1 and <YOUR_HTTP_ENDPOINT>
2 with your own values.
curl \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
"agent": "informant",
"id": "my-test-polkadot-ah-all",
"args": {
"networks": ["urn:ocn:polkadot:1000"],
"filter": {
"type": "event",
"match": {
"section": "balances",
"method": "Deposit",
"data.amount": {
"$bn_gte": "50000000000"
}
}
}
},
"channels": [{
"type": "webhook",
"url": "<YOUR_HTTP_ENDPOINT>"
}]
}' \
https://api.ocelloids.net/subs
Executing the example request should return a 201 HTTP status code, and you will start receiving notifications on your endpoint.
Use
Templates
and contentType
to transform the payload in the format that your webhook expects.
-
If you don’t have an API key, please refer to Get an API key . ↩︎
-
You can use a service like https://webhook.site for testing out. ↩︎