Skip to content
Merged
6 changes: 6 additions & 0 deletions apify-api/openapi/code_samples/javascript/act_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.actor('<ACTOR ID>').delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/act_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 actor = await apifyClient
.actor('<ACTOR ID>')
.get();

console.log(actor);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/act_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 updatedActor = await apifyClient
.actor('<ACTOR ID>')
.update({
title: 'New title',
});

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

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.delete();
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>',
});
await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.envVar('MY_ENV_VAR')
.delete();
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 envVar = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.envVar('MY_ENV_VAR')
.get();

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

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedEnvVar = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.envVar('MY_ENV_VAR')
.update({
name: 'MY_ENV_VAR',
value: 'my-new-value',
});

console.log(updatedEnvVar);
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 { items } = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.envVars()
.list();

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

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const envVar = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.envVars()
.create({
name: 'MY_ENV_VAR',
value: 'my-new-value',
isSecret: true,
});

console.log(envVar);
11 changes: 11 additions & 0 deletions apify-api/openapi/code_samples/javascript/act_version_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 version = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.get();

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

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedVersion = await apifyClient
.actor('<ACTOR ID>')
.version('0.1')
.update({
buildTag: 'latest',
});

console.log(updatedVersion);
11 changes: 11 additions & 0 deletions apify-api/openapi/code_samples/javascript/act_versions_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 { items } = await apifyClient
.actor('<ACTOR ID>')
.versions()
.list();

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

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const version = await apifyClient
.actor('<ACTOR ID>')
.versions()
.create({
versionNumber: '0.1',
sourceType: 'GIT_REPO',
gitRepoUrl: 'https://github.com/my/repo',
});

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

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

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

const apifyClient = new ApifyClient({ token: 'my-token' });
const myActor = await apifyClient.actors().create({ name: 'my-actor' });
const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const myActor = await apifyClient
.actors()
.create({
name: '<ACTOR NAME>',
});

console.log(myActor);
Loading