-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add code samples for Storages (#1351)
- Loading branch information
1 parent
98ce77a
commit 8f36cb5
Showing
32 changed files
with
344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/dataset_items_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
apify-api/openapi/code_samples/javascript/dataset_items_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/datasets_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
8 changes: 8 additions & 0 deletions
8
apify-api/openapi/code_samples/javascript/keyValueStore_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/keyValueStore_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/keyValueStore_keys_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
apify-api/openapi/code_samples/javascript/keyValueStore_put.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
8 changes: 8 additions & 0 deletions
8
apify-api/openapi/code_samples/javascript/keyValueStore_record_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/keyValueStore_record_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
11 changes: 11 additions & 0 deletions
11
apify-api/openapi/code_samples/javascript/keyValueStore_record_put.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/keyValueStores_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/keyValueStores_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
8 changes: 8 additions & 0 deletions
8
apify-api/openapi/code_samples/javascript/requestQueue_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/requestQueue_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
apify-api/openapi/code_samples/javascript/requestQueue_head_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
12 changes: 12 additions & 0 deletions
12
apify-api/openapi/code_samples/javascript/requestQueue_head_lock_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
apify-api/openapi/code_samples/javascript/requestQueue_put.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
8 changes: 8 additions & 0 deletions
8
apify-api/openapi/code_samples/javascript/requestQueue_request_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/requestQueue_request_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 request = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.getRequest('<REQUEST ID>'); | ||
|
||
console.log(request); |
8 changes: 8 additions & 0 deletions
8
apify-api/openapi/code_samples/javascript/requestQueue_request_lock_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>') | ||
.deleteRequestLock('<REQUEST ID>'); |
15 changes: 15 additions & 0 deletions
15
apify-api/openapi/code_samples/javascript/requestQueue_request_lock_put.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 result = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.prolongRequestLock( | ||
'<REQUEST ID>', | ||
{ | ||
lockSecs: 3600, | ||
}, | ||
); | ||
|
||
console.log(result); |
13 changes: 13 additions & 0 deletions
13
apify-api/openapi/code_samples/javascript/requestQueue_request_put.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 result = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.updateRequest({ | ||
id: '<REQUEST ID>', | ||
url: 'http://example.com', | ||
}); | ||
|
||
console.log(result); |
13 changes: 13 additions & 0 deletions
13
apify-api/openapi/code_samples/javascript/requestQueue_requests_batch_delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 result = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.batchDeleteRequests([ | ||
{ uniqueKey: 'http://example.com' }, | ||
{ uniqueKey: 'http://example.com/2' }, | ||
]); | ||
|
||
console.log(result); |
21 changes: 21 additions & 0 deletions
21
apify-api/openapi/code_samples/javascript/requestQueue_requests_batch_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const result = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.batchAddRequests([ | ||
{ | ||
uniqueKey: 'http://example.com', | ||
url: 'http://example.com', | ||
method: 'GET', | ||
}, | ||
{ | ||
uniqueKey: 'http://example.com/2', | ||
url: 'http://example.com/2', | ||
method: 'GET', | ||
}, | ||
]); | ||
|
||
console.log(result); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/requestQueue_requests_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
.requestQueue('<QUEUE ID>') | ||
.listRequests(); | ||
|
||
console.log(items); |
14 changes: 14 additions & 0 deletions
14
apify-api/openapi/code_samples/javascript/requestQueue_requests_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const result = await apifyClient | ||
.requestQueue('<QUEUE ID>') | ||
.addRequest({ | ||
'uniqueKey': 'http://example.com', | ||
'url': 'http://example.com', | ||
'method': 'GET', | ||
}); | ||
|
||
console.log(result); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/requestQueues_get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
.requestQueues() | ||
.list(); | ||
|
||
console.log(items); |
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/requestQueues_post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
.requestQueues() | ||
.getOrCreate('<QUEUE NAME>'); | ||
|
||
console.log(queue); |