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

Apify Client v1 #146

Merged
merged 136 commits into from
Oct 22, 2020
Merged
Changes from 1 commit
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
1ffc2fd
Reimplement first actor endpoints
mnmkng Sep 4, 2019
98dd092
Progress commit
mnmkng Dec 31, 2019
6fc594c
Completed tests for actors endpoint.
petrpatek Dec 31, 2019
3f0fa6c
Task endpoint partial rewrote.
petrpatek Dec 31, 2019
819012b
rewrote users.
petrpatek Dec 31, 2019
a86bd4d
rewrote logs.js
petrpatek Dec 31, 2019
2208ea5
started dataset rewrote.
petrpatek Jan 2, 2020
f66a4ba
keyValuesStores basic methods rewrote.
petrpatek Jan 6, 2020
a5ffb60
rewrote request_queues.js
petrpatek Jan 6, 2020
634af0e
rewrote webhooks.js
petrpatek Jan 6, 2020
cc7057d
rewrote webhook_dispatches.js.
petrpatek Jan 6, 2020
503def2
rewrote dataset tests. Removed Crawler.
petrpatek Jan 11, 2020
165520b
rewrote key_value_stores.js tests
petrpatek Jan 13, 2020
ec90fdf
xited tests that are not working, because of the client implementatio…
petrpatek Jan 13, 2020
5a1c71a
stuck in rewriting to async-retry.
petrpatek Jan 14, 2020
80d1ff6
fixed exponential backoff... I guess
petrpatek Jan 28, 2020
e8a55fa
make working browser POC.
petrpatek Jan 29, 2020
00c7638
make browser test work.
petrpatek Feb 14, 2020
ce86a42
used brotli compressor to reduce the bundle size.
petrpatek Feb 17, 2020
bebeb3b
Merge remote-tracking branch 'origin/master' into feature/isomorphic
petrpatek Feb 17, 2020
e96514c
introduced latest features from master.
petrpatek Feb 17, 2020
4887c61
refactored code. split lodash to functions because of the bundle size.
petrpatek Feb 17, 2020
3773cc4
removed deprecated method from task
petrpatek Feb 17, 2020
f953264
fixed lint err
petrpatek Feb 17, 2020
c72697b
added workflows.
petrpatek Feb 17, 2020
1622133
improved build script to build files for the test.
petrpatek Feb 17, 2020
9b96984
removed prepare script.
petrpatek Feb 17, 2020
f523460
split build to two parts.
petrpatek Feb 17, 2020
d24a225
improved webpack browser build.
petrpatek Feb 17, 2020
b9938df
removed unnecessary dependencies and engines.
petrpatek Feb 17, 2020
7eea3e4
migrated to jest due to performance
petrpatek Feb 17, 2020
24974f7
fixed lint
petrpatek Feb 17, 2020
a88d4a3
made tests green again,
petrpatek Feb 18, 2020
29a66fc
started abstract class.
petrpatek Feb 18, 2020
9d2cfe5
Comments from PR.
petrpatek Feb 20, 2020
81b3d74
renamed edpoint to resource. Deleted extra expbackoff logic from data…
petrpatek Feb 20, 2020
12208e0
changed webpack mode.
petrpatek Feb 20, 2020
af99d39
added defaults.
petrpatek Feb 20, 2020
9ab5568
improved text decoding.
petrpatek Feb 20, 2020
2bed4fa
documented listActors endpoint.
petrpatek Feb 20, 2020
d827a7d
updated docs for actor endpoint.
petrpatek Feb 21, 2020
d7fded2
improved dataset endpoint docs.
petrpatek Feb 21, 2020
2df3d35
documented dataset endpoint.
petrpatek Feb 21, 2020
f164895
improved KV stores docs.
petrpatek Feb 21, 2020
0f1082d
logs docs slightly improved.
petrpatek Feb 21, 2020
c39b07a
Request queue docs improved.
petrpatek Feb 21, 2020
4963927
improved tasks docs.
petrpatek Feb 22, 2020
a29bd00
documented user endpoint.
petrpatek Feb 22, 2020
d763168
documented webhook dispatches
petrpatek Feb 22, 2020
3ca1579
documented webhooks endpoint.
petrpatek Feb 22, 2020
89c8589
added build docs action.
petrpatek Feb 24, 2020
d2d3744
improved docs strategy.
petrpatek Feb 24, 2020
616b6c8
fixed yml
petrpatek Feb 24, 2020
8456f68
fix
petrpatek Feb 24, 2020
ea957b4
refactored actions.
petrpatek Feb 24, 2020
c7a0f07
refactored actions.
petrpatek Feb 24, 2020
b958310
renamed.
petrpatek Feb 24, 2020
02d4a68
on added
petrpatek Feb 24, 2020
0321852
increased version added my parameter to list actors endpoint.
petrpatek Feb 24, 2020
4ccc2b1
added dist
petrpatek Feb 24, 2020
20173bc
fix because of null from integration tests.
petrpatek Feb 24, 2020
972d5d6
renamed tilde separated to slash separated.
petrpatek Feb 25, 2020
dcded5e
added missing return.
petrpatek Feb 25, 2020
464d04b
Fixed docs. Improved README.md. Added CHANGELOG.md. Bump version.
petrpatek Mar 3, 2020
6f50096
Added possibility to remove content-type header with null and fixed J…
petrpatek Mar 22, 2020
1e1ea72
fixed getValue
petrpatek Mar 22, 2020
edb560d
Implementing schedules API
mtrunkat Mar 24, 2020
232d1cc
Adding tests and linting
mtrunkat Mar 24, 2020
2b60154
fixed header removal and log endpoint.
petrpatek Mar 24, 2020
d9c2e47
Merge pull request #139 from apifytech/feature/schedules
petrpatek Mar 24, 2020
f1b3881
improved log tests increased beta version.
petrpatek Mar 24, 2020
3642fe1
Fix typo in version
mnmkng Mar 25, 2020
c041286
Fix lint
mnmkng Mar 25, 2020
4f66e4f
Fixed tasks endpoint
petrpatek Mar 30, 2020
678c1d7
fixed signing url. task input handling.
petrpatek Mar 31, 2020
c33bc35
Merge branch 'feature/isomorphic' of github.com:apifytech/apify-clien…
petrpatek Mar 31, 2020
91eee0d
removed babel for nodeJs.
petrpatek Apr 1, 2020
32c97eb
improved browser header to don't trigger error.
petrpatek Apr 1, 2020
28cac26
fixed docs.
petrpatek Apr 1, 2020
5782a2a
bump version
petrpatek Apr 1, 2020
a6185ce
Some changes
mnmkng Apr 19, 2020
61f6223
Not great, not terrible
mnmkng Jun 9, 2020
16bd1a5
Add missing clients
mnmkng Jun 9, 2020
b4b6464
Add clients to index
mnmkng Jun 9, 2020
1eb64b6
Dataset tests work
mnmkng Jun 10, 2020
cabb896
Dataset tests pass
mnmkng Jun 12, 2020
926616a
Key value stores
mnmkng Jun 17, 2020
5099c2d
Key value stores finished
mnmkng Jun 22, 2020
cca7c8d
Logs finished
mnmkng Jun 22, 2020
0c067f6
Request queue finished
mnmkng Jun 22, 2020
61f14bc
Schedules finished
mnmkng Jun 22, 2020
ac7dd9e
Tasks finished
mnmkng Jun 23, 2020
8a17bad
Users finished
mnmkng Jun 23, 2020
c019b50
Webhooks finished
mnmkng Jun 23, 2020
8fa92f4
Webhook Dispatches finished
mnmkng Jun 23, 2020
2b15949
Remove old stuff, refactor, fix tests
mnmkng Jun 23, 2020
6baeee2
Test Statistics
mnmkng Jun 23, 2020
ad8027c
Bump version
mnmkng Jun 24, 2020
cc5452b
Minor improvements
mnmkng Jul 22, 2020
f25f65b
Add response parsing logic
mnmkng Jul 22, 2020
77f3094
Add status params to actor runs endpoint
mnmkng Aug 25, 2020
785e9ce
Fix axios defaults
mnmkng Sep 2, 2020
9700d2d
Bump version
mnmkng Sep 2, 2020
ba63a57
Update KVS, bump version
mnmkng Sep 5, 2020
27fb35b
Lint files
mnmkng Sep 5, 2020
dd46dcd
Some changes
mnmkng Sep 8, 2020
04cc125
Merge branch 'chore/refactoring' of github.com:apify/apify-client-js …
jbartadev Sep 9, 2020
6b4340c
Minor improvements
mnmkng Sep 18, 2020
adb0a71
Merge branch 'chore/refactoring' of github.com:apify/apify-client-js …
jbartadev Sep 21, 2020
52a90e3
Add waitForFinish function to Run and Build
mnmkng Oct 2, 2020
c3caee2
Add waitForFinish tests
mnmkng Oct 2, 2020
27ae925
Fix lint
mnmkng Oct 2, 2020
fbf0b01
Merge branch 'chore/refactoring' of github.com:apify/apify-client-js …
jbartadev Oct 2, 2020
3cc3b4a
Added call method to actor
jbartadev Oct 2, 2020
4f9f53b
Fix invalid return value in getRecord
mnmkng Oct 5, 2020
5724d28
Merge branch 'chore/refactoring' of github.com:apify/apify-client-js …
jbartadev Oct 5, 2020
b8ce886
Fix setRecord with stringified JSON, remove lodash
mnmkng Oct 6, 2020
2b07cc5
Added private method _call to resource client
jbartadev Oct 6, 2020
ad5d99c
Added call method to task client, update actor call method
jbartadev Oct 6, 2020
ca40649
Bump version
mnmkng Oct 6, 2020
e63d263
Added call method tests
jbartadev Oct 6, 2020
13a6ed8
Merge branch 'chore/refactoring' into refactor/v1
jbartadev Oct 6, 2020
3850a50
fixed condition
jbartadev Oct 6, 2020
2df33ef
further refactoring
jbartadev Oct 7, 2020
0c1064e
small changes & made tests green again
jbartadev Oct 9, 2020
cdb1e95
Merge pull request #144 from apify/refactor/v1
mnmkng Oct 9, 2020
a715a36
Bump version
mnmkng Oct 9, 2020
304500d
Change signature of start and call methods
mnmkng Oct 13, 2020
0c185cd
Update comment
mnmkng Oct 13, 2020
ff0dea9
Change metamorph signature
mnmkng Oct 13, 2020
631b1ee
Improve ApifyApiError
mnmkng Oct 14, 2020
a8be029
Fix trailing slash and add some improvements
mnmkng Oct 14, 2020
93db7fb
Bump version
mnmkng Oct 14, 2020
aea26b8
Fix v2 in baseUrl and tests
mnmkng Oct 14, 2020
ff19d9c
Improve error logging, fix 404 on redirects
mnmkng Oct 14, 2020
8be38ec
Add browser test for api error, test node 14 not 10
mnmkng Oct 22, 2020
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
Prev Previous commit
Next Next commit
documented dataset endpoint.
  • Loading branch information
petrpatek committed Feb 21, 2020
commit 2df3d3500ebbb6858bc6dedae9b6eb8c3f896468
109 changes: 46 additions & 63 deletions src/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,17 @@ export const BACKOFF_MILLIS = 200;
* Datasets
* @memberOf ApifyClient
* @description
* ### Basic usage
* ```javascript
* const ApifyClient = require('apify-client');
*
* const apifyClient = new ApifyClient({
* userId: 'RWnGtczasdwP63Mak',
* token: 'f5J7XsdaKDyRywwuGGo9',
* });
* const datasets = apifyClient.datasets;
* This section describes API endpoints to manage Datasets.
* Dataset is a storage for structured data where each record stored has the same attributes,
* such as online store products or real estate offers.
* You can imagine it as a table, where each object is a row and its attributes are columns.
* Dataset is an append-only storage - you can only add new records to it but you cannot modify or remove existing records.
* Typically it is used to store crawling results. For more information, see the [Dataset documentation](https://docs.apify.com/storage#dataset).
* Note that some of the endpoints do not require the authentication token, the calls are authenticated using the hard-to-guess ID of the dataset.
*
* // Get dataset with name 'my-dataset' and set it as default
* // to be used in following commands.
* const dataset = await datasets.getOrCreateDataset({
* datasetName: 'my-dataset',
* });
* apifyClient.setOptions({ datasetId: dataset.id });
* For more details see (dataset endpoint)[https://docs.apify.com/api/v2#/reference/datasets]
*
* // Save some object and array of objects to dataset.
* await datasets.putItems({
* data: { foo: 'bar' }
* });
* await datasets.putItems({
* data: [{ foo: 'hotel' }, { foo: 'restaurant' }],
* });
*
* // Get items from dataset and delete it.
* const paginationList = await datasets.getItems();
* const items = paginationList.items;
* await datasets.deleteDataset();
* ```
*
* Every method can be used as either promise or with callback. If your Node version supports await/async then you can await promise result.
* ```javascript
* // Awaited promise
* try {
* const items = await datasets.getItems();
* // Do something with the items ...
* } catch (err) {
* // Do something with error ...
* }
*
* // Promise
* datasets.getItems()
* .then((paginationList) => {
* console.log(paginationList.items)
* // Do something with items ...
* })
* .catch((err) => {
* // Do something with error ...
* });
*
* // Callback
* datasets.getItems((err, paginationList) => {
* console.log(paginationList.items)
* // Do something with error or items ...
* });
* ```
* @namespace datasets
*/

Expand All @@ -80,7 +34,9 @@ export default class Datasets extends Resource {
}

/**
* Creates dataset of given name and returns it's object. If data with given name already exists then returns it's object.
* Creates dataset of given name and returns its object. If dataset with given name already exists then returns its object.
*
* For more details see (create dataset endpoint)[https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/create-dataset]
*
* @memberof ApifyClient.datasets
* @instance
Expand Down Expand Up @@ -116,6 +72,8 @@ export default class Datasets extends Resource {
* To sort them in descending order, use `desc: true` option.
* The endpoint supports pagination using limit and offset parameters and it will not return more than 1000 array elements.
*
* For more details see (list datasets endpoint)[https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/get-list-of-datasets]
*
* @memberof ApifyClient.datasets
* @instance
* @param {Object} options
Expand All @@ -127,7 +85,6 @@ export default class Datasets extends Resource {
* If `true` then the objects are sorted by the startedAt field in descending order.
* @param {Boolean} [options.unnamed]
* If `true` then also unnamed stores will be returned. By default only named stores are returned.
* @param callback
* @returns {PaginationList}
*/
async listDatasets(options = {}) {
Expand Down Expand Up @@ -158,13 +115,15 @@ export default class Datasets extends Resource {
/**
* Returns given dataset.
*
* For more details see (get dataset endpoint)[https://docs.apify.com/api/v2#/reference/datasets/dataset/get-dataset]
*
* @memberof ApifyClient.datasets
* @instance
* @param {Object} options
* @param {String} options.datasetId - Unique dataset ID
* @param {String} options.datasetId - Unique dataset ID Dataset ID or username~dataset-name;
* // TODO: Not sure about the token
* @param {String} [options.token] - Your API token at apify.com. This parameter is required
* only when using "username~dataset-name" format for datasetId.
* @param callback
* @returns {Dataset}
*/
async getDataset(options = {}) {
Expand Down Expand Up @@ -215,13 +174,14 @@ export default class Datasets extends Resource {
/**
* Deletes given dataset.
*
* For more details see (delete dataset endpoint)[https://docs.apify.com/api/v2#/reference/datasets/dataset/delete-dataset]
*
* @memberof ApifyClient.datasets
* @instance
* @param {Object} options
* @param {String} options.datasetId - Unique dataset ID
* @param {String} [options.token] - Your API token at apify.com. This parameter is required
* only when using "username~dataset-name" format for datasetId.
* @param callback
* @returns {*}
*/
async deleteDataset(options = {}) {
Expand All @@ -239,15 +199,31 @@ export default class Datasets extends Resource {
}

/**
* Returns items in the dataset based on the provided parameters
* Returns data stored in the dataset in a desired format.
*
* The format of the response depends on format option.
*
* Note that CSV, XLSX and HTML tables are limited to 500 columns and the column names cannot be longer than 200 characters.
* JSON, XML and RSS formats do not have such restrictions.
*
* The top-level fields starting with the # character are considered hidden.
* These are useful to store debugging information and can be omitted from the output
* by providing the `skipHidden: true` or `clean: true` query parameters.
*
* The generated response supports pagination.
* The maximum number of items that will be returned in a single API call is limited to 250,000.
* If you specify `desc: true` query parameter,
* the results are returned in the reverse order than they were stored (i.e. from newest to oldest items)
*
* For more details see (get items endpoint)[https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items]
*
* @memberof ApifyClient.datasets
* @instance
* @param {Object} options
* @param {String} options.datasetId
* Unique dataset ID
* @param {String} [options.format='json']
* Format of the `items` property, possible values are: `json`, `csv`, `xlsx`, `html`, `xml` and `rss`.
* The format parameter can have one of the following values: json, jsonl, xml, html, csv, xlsx and rss.
* @param {Number} [options.offset=0]
* Number of array elements that should be skipped at the start.
* @param {Number} [options.limit=250000]
Expand Down Expand Up @@ -299,7 +275,7 @@ export default class Datasets extends Resource {
* @param {String} [options.token]
* Your API token at apify.com. This parameter is required
* only when using "username~dataset-name" format for datasetId.
* @param callback
* TODO: is really necessary?
* @returns {PaginationList}
*/
async getItems(options = {}) {
Expand Down Expand Up @@ -374,7 +350,13 @@ export default class Datasets extends Resource {
}

/**
* Saves the object or an array of objects into dataset.
* Appends an item or an array of items to the end of the dataset.
* The `data` option is a JSON object or a JSON array of objects to save into the dataset.
*
* **IMPORTANT**: The limit of request payload size for the dataset is 5 MB.
* If the array exceeds the size, you'll need to split it into a number of smaller arrays.
*
* For more details see (put items endpoint)[https://docs.apify.com/api/v2#/reference/datasets/item-collection/put-items]
*
* @memberof ApifyClient.datasets
* @instance
Expand All @@ -384,6 +366,7 @@ export default class Datasets extends Resource {
* Arrays and Objects must be JSON.stringifiable.
* @param {String} [options.token] - Your API token at apify.com. This parameter is required
* only when using "username~dataset-name" format for datasetId.
* TODO: is really necessary?
* @returns {*}
*/
async putItems(options = {}) {
Expand Down