Skip to content

Commit 53c7b02

Browse files
authored
feat: add code samples for Webhooks (#1354)
1 parent 8f36cb5 commit 53c7b02

File tree

10 files changed

+98
-0
lines changed

10 files changed

+98
-0
lines changed

apify-api/openapi/code_samples/javascript/requestQueue_request_put.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const result = await apifyClient
77
.requestQueue('<QUEUE ID>')
88
.updateRequest({
99
id: '<REQUEST ID>',
10+
uniqueKey: 'http://example.com',
1011
url: 'http://example.com',
1112
});
1213

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)