Skip to content

Commit

Permalink
feat: add code samples for Schedules, Users, Store (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-murasovs authored Dec 20, 2024
1 parent 53c7b02 commit 8c0df15
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/log_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 log = await apifyClient
.log('<BUILD OR RUN ID>')
.get();

console.log(log);
8 changes: 8 additions & 0 deletions apify-api/openapi/code_samples/javascript/schedule_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
.schedule('<SCHEDULE ID>')
.delete();
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/schedule_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 schedule = await apifyClient
.schedule('<SCHEDULE ID>')
.get();

console.log(schedule);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/schedule_log_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 log = await apifyClient
.schedule('<SCHEDULE ID>')
.getLog();

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

console.log(updatedSchedule);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/schedules_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
.schedules()
.list();

console.log(items);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/schedules_post.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 schedule = await apifyClient
.schedules()
.create({
name: '<SCHEDULE NAME>',
});

console.log(schedule);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/store_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
.store()
.list();

console.log(items);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/user_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 user = await apifyClient
.user('<USER ID>')
.get();

console.log(user);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/users_me_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 user = await apifyClient
.user('me')
.get();

console.log(user);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/users_me_limits_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 limits = await apifyClient
.user('me')
.limits();

console.log(limits);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/users_me_limits_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 updatedLimits = await apifyClient
.user('me')
.updateLimits({
dataRetentionDays: 5,
});

console.log(updatedLimits);
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 usage = await apifyClient
.user('me')
.monthlyUsage();

console.log(usage);

0 comments on commit 8c0df15

Please sign in to comment.