Skip to content

Commit 5ed4efa

Browse files
committed
feat: add code samples for webhooks
1 parent 0588349 commit 5ed4efa

File tree

9 files changed

+97
-0
lines changed

9 files changed

+97
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const dispatch = await apifyClient
7+
.webhookDispatch('<DISPATCH ID>')
8+
.get();
9+
10+
console.log(dispatch);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.webhookDispatches()
8+
.list();
9+
10+
console.log(items);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.webhook('<WEBHOOK ID>')
8+
.delete();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.webhook('<WEBHOOK ID>')
8+
.dispatches()
9+
.list();
10+
11+
console.log(items);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const webhook = await apifyClient
7+
.webhook('<WEBHOOK ID>')
8+
.get();
9+
10+
console.log(webhook);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const updatedWebhook = await apifyClient
7+
.webhook('<WEBHOOK ID>')
8+
.update({
9+
eventTypes: ['ACTOR.RUN.FAILED'],
10+
});
11+
12+
console.log(updatedWebhook);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const result = await apifyClient
7+
.webhook('<WEBHOOK ID>')
8+
.test();
9+
10+
console.log(result);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.webhooks()
8+
.list();
9+
10+
console.log(items);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const webhook = await apifyClient
7+
.webhooks()
8+
.create({
9+
eventTypes: ['ACTOR.RUN.SUCCEEDED'],
10+
condition: {
11+
actorId: '<ACTOR ID>',
12+
},
13+
requestUrl: 'http://example.com/',
14+
});
15+
16+
console.log(webhook);

0 commit comments

Comments
 (0)