Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add code samples for Webhooks #1354

Merged
merged 42 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5d0f92a
Add JS samples for Actor object
m-murasovs Dec 9, 2024
0311730
feat: update var name
m-murasovs Dec 9, 2024
b71a562
feat: add code samples for the Actor versions
m-murasovs Dec 9, 2024
8caa325
feat: add env vars code samples
m-murasovs Dec 9, 2024
a7a97ac
rename env var
m-murasovs Dec 10, 2024
2c3a654
feat: add webhooks code samples
m-murasovs Dec 10, 2024
0232065
fix: change / to ~ in actor tech name in samples
m-murasovs Dec 10, 2024
88f6c7c
feat: add the builds and runs samples
m-murasovs Dec 10, 2024
f90260f
Merge branch 'master' into feat/code-samples-actor-obj
m-murasovs Dec 10, 2024
b90c617
Merge branch 'master' into feat/code-samples-versions
m-murasovs Dec 10, 2024
b876539
Merge branch 'master' into feat/code-samples-webhooks-builds-runs
m-murasovs Dec 10, 2024
1c68faa
feat: add code samples for tasks
m-murasovs Dec 10, 2024
d78401d
feat: add more tasks samples
m-murasovs Dec 10, 2024
a4d0778
feat: add code samples for Actor runs
m-murasovs Dec 10, 2024
cc563ff
add update run sample
m-murasovs Dec 10, 2024
00fb2ba
feat: add code samples for builds
m-murasovs Dec 10, 2024
0e803ad
fix: better IDs and minimize side scroll
m-murasovs Dec 11, 2024
cd5c119
Merge branch 'master' into feat/code-samples-actor-obj
m-murasovs Dec 11, 2024
836ea08
Merge branch 'feat/code-samples-actor-obj' into feat/code-samples-ver…
m-murasovs Dec 11, 2024
766838e
fix: better IDs and make code narrower
m-murasovs Dec 11, 2024
dfb8ec2
Merge branch 'master' into feat/code-samples-webhooks-builds-runs
m-murasovs Dec 11, 2024
43340ad
Merge branch 'feat/code-samples-versions' into feat/code-samples-webh…
m-murasovs Dec 11, 2024
e441c41
fix: better IDs and avoid side scroll
m-murasovs Dec 11, 2024
6a75eb4
Merge branch 'feat/code-samples-webhooks-builds-runs' into feat/code-…
m-murasovs Dec 11, 2024
d57d035
fix: better IDs and narrower examples
m-murasovs Dec 11, 2024
73fd227
Merge branch 'feat/code-samples-tasks' into feat/code-samples-runs
m-murasovs Dec 11, 2024
8b11936
fix: better IDs and narrower code
m-murasovs Dec 11, 2024
7490d31
Merge branch 'master' into feat/code-samples-runs
m-murasovs Dec 12, 2024
0588349
feat: add code samples for storages
m-murasovs Dec 12, 2024
5ed4efa
feat: add code samples for webhooks
m-murasovs Dec 12, 2024
98e30d5
fix examples
m-murasovs Dec 13, 2024
514444e
Merge branch 'master' into feat/code-samples-tasks
m-murasovs Dec 13, 2024
27e3ced
Merge branch 'feat/code-samples-tasks' into feat/code-samples-runs
m-murasovs Dec 13, 2024
db4ea5e
Merge branch 'feat/code-samples-runs' into feat/code-samples-storages
m-murasovs Dec 13, 2024
53145cf
Merge branch 'feat/code-samples-storages' into feat/code-samples-webh…
m-murasovs Dec 13, 2024
5088bfc
fix quote marks
m-murasovs Dec 13, 2024
068a71a
Merge branch 'master' into feat/code-samples-runs
m-murasovs Dec 13, 2024
f077f7c
fix quote marks
m-murasovs Dec 13, 2024
c9b8f91
Merge branch 'feat/code-samples-runs' into feat/code-samples-storages
m-murasovs Dec 13, 2024
a835655
Merge branch 'feat/code-samples-storages' into feat/code-samples-webh…
m-murasovs Dec 13, 2024
8d83e2f
fix the missing uniqueKey
m-murasovs Dec 17, 2024
521b1cb
Merge branch 'master' into feat/code-samples-webhooks
m-murasovs Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apify-api/openapi/code_samples/javascript/act_runs_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const apifyClient = new ApifyClient({
});
const run = await apifyClient
.actor('<ACTOR ID>')
.start({ 'foo': 'bar' });
.start({ foo: 'bar' });

console.log(run);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorBuild_abort_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const abortedBuild = await apifyClient
.build('<BUILD ID>')
.abort();

console.log(abortedBuild);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient.build('<BUILD ID>').delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorBuild_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const build = await apifyClient
.build('<BUILD ID>')
.get();

console.log(build);
11 changes: 11 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorBuild_log_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const buildLog = await apifyClient
.build('<BUILD ID>')
.log()
.get();

console.log(buildLog);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorBuilds_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.builds()
.list();

console.log(items);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_abort_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const abortedRun = await apifyClient
.run('<RUN ID>')
.abort();

console.log(abortedRun);
6 changes: 6 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient.run('<RUN ID>').delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const run = await apifyClient
.run('<RUN ID>')
.get();

console.log(run);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const metamorphedRun = await apifyClient
.run('<RUN ID>')
.metamorph('<ACTOR ID>');

console.log(metamorphedRun);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedRun = await apifyClient
.run('<RUN ID>')
.update({
statusMessage: 'Actor has finished',
});

console.log(updatedRun);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_reboot_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const rebootedRun = await apifyClient
.run('<RUN ID>')
.reboot();

console.log(rebootedRun);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const resurrectedRun = await apifyClient
.run('<RUN ID>')
.resurrect();

console.log(resurrectedRun);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRuns_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.runs()
.list();

console.log(items);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const apifyClient = new ApifyClient({
});
const updatedInput = await apifyClient
.task('<TASK ID>')
.updateInput({ 'foo': 'baz' });
.updateInput({ foo: 'baz' });

console.log(updatedInput);
8 changes: 8 additions & 0 deletions apify-api/openapi/code_samples/javascript/dataset_delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.dataset('<DATASET ID>')
.delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/dataset_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const dataset = await apifyClient
.dataset('<DATASET ID>')
.get();

console.log(dataset);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/dataset_items_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.dataset('<DATASET ID>')
.listItems();

console.log(items);
11 changes: 11 additions & 0 deletions apify-api/openapi/code_samples/javascript/dataset_items_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.dataset('<DATASET ID>')
.pushItems([
{ foo: 'bar' },
{ fizz: 'buzz' },
]);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/dataset_put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedDataset = await apifyClient
.dataset('<DATASET ID>')
.update({
title: 'New title',
});

console.log(updatedDataset);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/datasets_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.datasets()
.list();

console.log(items);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/datasets_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const dataset = await apifyClient
.datasets()
.getOrCreate('<DATASET NAME>');

console.log(dataset);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.keyValueStore('<STORE ID>')
.delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/keyValueStore_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const store = await apifyClient
.keyValueStore('<STORE ID>')
.get();

console.log(store);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.keyValueStore('<STORE ID>')
.listKeys();

console.log(items);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/keyValueStore_put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedStore = await apifyClient
.keyValueStore('<STORE ID>')
.update({
title: 'New title',
});

console.log(updatedStore);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.keyValueStore('<STORE ID>')
.deleteRecord('<RECORD KEY>');
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const record = await apifyClient
.keyValueStore('<STORE ID>')
.getRecord('<RECORD KEY>');

console.log(record);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.keyValueStore('<STORE ID>')
.setRecord({
key: '<RECORD KEY>',
value: 'my value',
});
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/keyValueStores_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.keyValueStores()
.list();

console.log(items);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/keyValueStores_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const store = await apifyClient
.keyValueStores()
.getOrCreate('<STORE NAME>');

console.log(store);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.requestQueue('<QUEUE ID>')
.delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/requestQueue_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const queue = await apifyClient
.requestQueue('<QUEUE ID>')
.get();

console.log(queue);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/requestQueue_head_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const head = await apifyClient
.requestQueue('<QUEUE ID>')
.listHead();

console.log(head);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const result = await apifyClient
.requestQueue('<QUEUE ID>')
.listAndLockHead({
lockSecs: 300,
});

console.log(result);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/requestQueue_put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedQueue = await apifyClient
.requestQueue('<QUEUE ID>')
.update({
title: 'New title',
});

console.log(updatedQueue);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.requestQueue('<QUEUE ID>')
.deleteRequest('<REQUEST ID>');
Loading
Loading