{"id":18486919,"url":"https://github.com/apify/apify-client-js","last_synced_at":"2025-11-03T16:27:26.267Z","repository":{"id":38355811,"uuid":"90863121","full_name":"apify/apify-client-js","owner":"apify","description":"Apify API client for JavaScript / Node.js.","archived":false,"fork":false,"pushed_at":"2025-03-31T14:25:37.000Z","size":19344,"stargazers_count":70,"open_issues_count":25,"forks_count":31,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-03T01:14:10.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.apify.com/api/client/js","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-10T12:43:36.000Z","updated_at":"2025-03-28T15:24:50.000Z","dependencies_parsed_at":"2023-07-16T11:13:59.706Z","dependency_job_id":"edeed4b7-3b9b-4f0f-b0bc-dfbd77c916a1","html_url":"https://github.com/apify/apify-client-js","commit_stats":{"total_commits":1001,"total_committers":42,"mean_commits":"23.833333333333332","dds":0.7522477522477522,"last_synced_commit":"3d9c64d5442b4f8f27c2b19dd98dd3b758944287"},"previous_names":["apifytech/apify-client-js"],"tags_count":501,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apify","download_url":"https://codeload.github.com/apify/apify-client-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713256,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T12:49:57.670Z","updated_at":"2025-11-03T16:27:26.239Z","avatar_url":"https://github.com/apify.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Apify API client for JavaScript\n\n`apify-client` is the official library to access [Apify API](https://docs.apify.com/api/v2) from your\nJavaScript applications. It runs both in Node.js and browser and provides useful features like\nautomatic retries and convenience functions that improve the experience of using the Apify API.\n\n\u003c!-- toc --\u003e\n\n- [Quick Start](#quick-start)\n- [Features](#features)\n    - [Automatic parsing and error handling](#automatic-parsing-and-error-handling)\n    - [Retries with exponential backoff](#retries-with-exponential-backoff)\n    - [Convenience functions and options](#convenience-functions-and-options)\n- [Usage concepts](#usage-concepts)\n    - [Nested clients](#nested-clients)\n    - [Pagination](#pagination)\n- [API Reference](#api-reference)\n\n\u003c!-- tocstop --\u003e\n\n## Quick Start\n\n```js\nconst { ApifyClient } = require('apify-client');\n\nconst client = new ApifyClient({\n    token: 'MY-APIFY-TOKEN',\n});\n\n// Starts an actor and waits for it to finish.\nconst { defaultDatasetId } = await client.actor('john-doe/my-cool-actor').call();\n// Fetches results from the actor's dataset.\nconst { items } = await client.dataset(defaultDatasetId).listItems();\n```\n\n## Features\n\nBesides greatly simplifying the process of querying the Apify API, the client provides other useful features.\n\n### Automatic parsing and error handling\n\nBased on the endpoint, the client automatically extracts the relevant data and returns it in the\nexpected format. Date strings are automatically converted to `Date` objects. For exceptions,\nwe throw an `ApifyApiError`, which wraps the plain JSON errors returned by API and enriches\nthem with other context for easier debugging.\n\n### Retries with exponential backoff\n\nNetwork communication sometimes fails, that's a given. The client will automatically retry requests that\nfailed due to a network error, an internal error of the Apify API (HTTP 500+) or rate limit error (HTTP 429).\nBy default, it will retry up to 8 times. First retry will be attempted after ~500ms, second after ~1000ms\nand so on. You can configure those parameters using the `maxRetries` and `minDelayBetweenRetriesMillis`\noptions of the `ApifyClient` constructor.\n\n### Convenience functions and options\n\nSome actions can't be performed by the API itself, such as indefinite waiting for an actor run to finish\n(because of network timeouts). The client provides convenient `call()` and `waitForFinish()` functions that do that.\nKey-value store records can be retrieved as objects, buffers or streams via the respective options, dataset items\ncan be fetched as individual objects or serialized data and we plan to add better stream support and async iterators.\n\n## Usage concepts\n\nThe `ApifyClient` interface follows a generic pattern that is applicable to all of its components.\nBy calling individual methods of `ApifyClient`, specific clients which target individual API\nresources are created. There are two types of those clients. A client for management of a single\nresource and a client for a collection of resources.\n\n```js\nconst { ApifyClient } = require('apify-client');\nconst apifyClient = new ApifyClient({ token: 'my-token' });\n\n// Collection clients do not require a parameter.\nconst actorCollectionClient = apifyClient.actors();\n// Creates an actor with the name: my-actor.\nconst myActor = await actorCollectionClient.create({ name: 'my-actor' });\n// Lists all of your actors.\nconst { items } = await actorCollectionClient.list();\n```\n\n```js\n// Collection clients do not require a parameter.\nconst datasetCollectionClient = apifyClient.datasets();\n// Gets (or creates, if it doesn't exist) a dataset with the name of my-dataset.\nconst myDataset = await datasetCollectionClient.getOrCreate('my-dataset');\n```\n\n```js\n// Resource clients accept an ID of the resource.\nconst actorClient = apifyClient.actor('john-doe/my-actor');\n// Fetches the john-doe/my-actor object from the API.\nconst myActor = await actorClient.get();\n// Starts the run of john-doe/my-actor and returns the Run object.\nconst myActorRun = await actorClient.start();\n```\n\n```js\n// Resource clients accept an ID of the resource.\nconst datasetClient = apifyClient.dataset('john-doe/my-dataset');\n// Appends items to the end of john-doe/my-dataset.\nawait datasetClient.pushItems([{ foo: 1 }, { bar: 2 }]);\n```\n\n\u003e The ID of the resource can be either the `id` of the said resource,\n\u003e or a combination of your `username/resource-name`.\n\nThis is really all you need to remember, because all resource clients\nfollow the pattern you see above.\n\n### Nested clients\n\nSometimes clients return other clients. That's to simplify working with\nnested collections, such as runs of a given actor.\n\n```js\nconst actorClient = apifyClient.actor('john-doe/hello-world');\nconst runsClient = actorClient.runs();\n// Lists the last 10 runs of the john-doe/hello-world actor.\nconst { items } = await runsClient.list({ limit: 10, desc: true });\n\n// Selects the last run of the john-doe/hello-world actor that finished\n// with a SUCCEEDED status.\nconst lastSucceededRunClient = actorClient.lastRun({ status: 'SUCCEEDED' });\n// Fetches items from the run's dataset.\nconst { items } = await lastSucceededRunClient.dataset().listItems();\n```\n\n\u003e The quick access to `dataset` and other storages directly from the run\n\u003e client can now only be used with the `lastRun()` method, but the feature\n\u003e will be available to all runs in the future.\n\n### Pagination\n\nMost methods named `list` or `listSomething` return a [\u003ccode\u003ePromise.\u0026lt;PaginationList\u0026gt;\u003c/code\u003e](/api/interface/PaginatedList).\nThere are some exceptions though, like `listKeys` or `listHead` which paginate differently.\nThe results you're looking for are always stored under `items` and you can use the `limit`\nproperty to get only a subset of results. Other props are also available, depending on the method.\n\n## API Reference\n\nAll public classes, methods and their parameters can be inspected in the [API reference](https://docs.apify.com/api/client/js/reference).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fapify-client-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapify%2Fapify-client-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fapify-client-js/lists"}