@crawlee/core
Core set of classes required for Crawlee.
The crawlee package consists of several smaller packages, released separately under @crawlee namespace:
@crawlee/core: the base for all the crawler implementations, also contains things likeRequest,RequestQueue,RequestListorDatasetclasses@crawlee/cheerio: exportsCheerioCrawler@crawlee/playwright: exportsPlaywrightCrawler@crawlee/puppeteer: exportsPuppeteerCrawler@crawlee/linkedom: exportsLinkeDOMCrawler@crawlee/jsdom: exportsJSDOMCrawler@crawlee/basic: exportsBasicCrawler@crawlee/http: exportsHttpCrawler(which is used for creating@crawlee/jsdomand@crawlee/cheerio)@crawlee/browser: exportsBrowserCrawler(which is used for creating@crawlee/playwrightand@crawlee/puppeteer)@crawlee/memory-storage:@apify/storage-localalternative@crawlee/browser-pool: previouslybrowser-poolpackage@crawlee/utils: utility methods@crawlee/types: holds TS interfaces mainly about theStorageBackend
Installing Crawlee
Most of the Crawlee packages are extending and reexporting each other, so it's enough to install just the one you plan on using, e.g. @crawlee/playwright if you plan on using playwright - it already contains everything from the @crawlee/browser package, which includes everything from @crawlee/basic, which includes everything from @crawlee/core.
If we don't care much about additional code being pulled in, we can just use the crawlee meta-package, which contains (re-exports) most of the @crawlee/* packages, and therefore contains all the crawler classes.
npm install crawlee
Or if all we need is cheerio support, we can install only @crawlee/cheerio.
npm install @crawlee/cheerio
When using playwright or puppeteer, we still need to install those dependencies explicitly - this allows the users to be in control of which version will be used.
npm install crawlee playwright
# or npm install @crawlee/playwright playwright
Alternatively we can also use the crawlee meta-package which contains (re-exports) most of the @crawlee/* packages, and therefore contains all the crawler classes.
Sometimes you might want to use some utility methods from
@crawlee/utils, so you might want to install that as well. This package contains some utilities that were previously available underApify.utils. Browser related utilities can be also found in the crawler packages (e.g.@crawlee/playwright).
Index
Result Stores
Scaling
Sources
Other
- EnqueueStrategy
- EventType
- LogLevel
- RequestState
- AfterCommitError
- ApifyLogAdapter
- ArgumentValidationError
- BaseCrawleeLogger
- Configuration
- CriticalError
- EventManager
- LocalEventManager
- Log
- Logger
- LoggerJson
- LoggerText
- MemoryStorageBackend
- NonRetryableError
- RecoverableState
- RequestManagerTandem
- RequestValidationError
- ServiceConflictError
- ServiceLocator
- SessionError
- StateValidationError
- StorageInstanceManager
- StorageStatsTracker
- StorageTransaction
- AddRequestsBatchedOptions
- AddRequestsBatchedResult
- ConfigField
- CrawleeLogger
- CrawleeLoggerOptions
- DatasetConsumer
- DatasetContent
- DatasetDataOptions
- DatasetExportOptions
- DatasetExportToOptions
- DatasetIteratorOptions
- DatasetJournalEntry
- DatasetMapper
- DatasetOptions
- DatasetReducer
- DatasetStats
- DefaultStorageIdentifier
- EventManagerOptions
- EventStatusMessageData
- IRequestLoader
- IRequestManager
- IStorage
- JournaledRequest
- KeyConsumer
- KeyValueStoreIteratorOptions
- KeyValueStoreJournalEntry
- KeyValueStoreOptions
- KeyValueStoreRawRecord
- KeyValueStoreStats
- LoadSignalInfo
- LocalEventManagerOptions
- LoggerOptions
- LogOptions
- MemoryStorageOptions
- ProxyConfigurationFunction
- ProxyConfigurationOptions
- PushErrorMessageOptions
- RecordOptions
- RecoverableStateOptions
- RecoverableStatePersistenceOptions
- RequestListOptions
- RequestListState
- RequestOptions
- RequestQueueJournalEntry
- RequestQueueOperationInfo
- RequestQueueOperationOptions
- RequestQueueOptions
- RequestQueueStats
- SchemaIssue
- StorageBackend
- StorageOpenOptions
- StorageTransactionOptions
- StorageTransactionView
- StorageWritePolicy
- SystemInfo
- UseStateOptions
- ConfigurationInput
- ConfigurationOptions
- EnqueueStrategyOption
- EventTypeName
- ExplicitStorageIdentifier
- FieldsInput
- FieldsOutput
- JournalEntry
- PacingScope
- PacingSignal
- RequestListSourcesFunction
- RequestLoaderStatus
- RequestsLike
- RequestSourceStatus
- ResolvedConfigValues
- SkippedRequestReason
- Source
- StateConversion
- StorageIdentifier
- StorageTransactionState
- StorageWriteMode
- SyncStateConversion
- coerceBoolean
- coerceNumber
- crawleeConfigFields
- log
- serviceLocator
- createStorageTransaction
- field
- parseValue
- purgeDefaultStorages
- resolveStorageIdentifier
- serializeValue
- useState
- withDirectStorageAccess
- withStorageTransaction
Other
ConfigurationInput
ConfigurationOptions
Deprecated - Use ConfigurationInput instead.
EnqueueStrategyOption
The strategy option accepted by ExtractLinksOptions and EnqueueUrlsOptions.
EventTypeName
ExplicitStorageIdentifier
A storage identifier where exactly one of id, name, or alias is specified.
Produced by resolveStorageIdentifier from ambiguous user input.
FieldsInput
Type parameters
- F: Record<string, ConfigField>
FieldsOutput
Type parameters
- F: Record<string, ConfigField>
JournalEntry
PacingScope
How much of the URL space a PacingSignal covers.
Open on purpose: 'hostname' and 'registrableDomain' are what Crawlee's own reporters send and what
ThrottlingRequestManager understands, but any string is accepted, so a pacer keyed on something
else can be reported to in its own vocabulary.
PacingSignal
Something said about the pace requests should go out at, reported to a request manager through IRequestManager.recordPacingSignal.
One shape rather than a method per channel: a pacing manager switches on reason, a wrapping one forwards the
value without knowing what is in it, and a new kind of signal costs the interface nothing. The url travels
inside the value because the crawl-wide variant has none. Nothing here names the mechanism a signal came
from - status codes, headers and robots.txt are the crawler's business - and every delay is in milliseconds.
Scope
A manager may apply a signal to a wider scope than it was given - a floor that holds for one host still holds when a whole site is paced by it - but never to a narrower one, which would leave some of the URLs the signal covers running unpaced. A manager that can only do the latter, or that does not recognise the scope at all, MUST throw rather than quietly under-apply it.
RequestListSourcesFunction
Type declaration
Returns Promise<RequestListSource[]>
RequestLoaderStatus
Loaders never stall — only a manager that paces its own dispatch can.
RequestsLike
RequestSourceStatus
A request source's own availability, in a single answer.
ready— the next IRequestLoader.fetchNextRequest is expected to hand something over.waiting— nothing to fetch right now, but the source is not done: requests are in progress, are being added in the background, or are held back untilreadyAt.stalled— the source holds requests it cannot make progress on. Only a manager that paces its own dispatch can reach this; see ThrottlingRequestManager.finished— everything has been handled.
ResolvedConfigValues
SkippedRequestReason
Source
StateConversion
One direction of the conversion between the state model and its persisted form - either a plain function, or a Standard Schema whose validated output is the result.
A schema that fails to validate makes RecoverableState throw a StateValidationError. Zod
codecs work directly, as their validation is the decode direction; use (state) => codec.encode(state) for the
other one.
Type parameters
- TFrom
- TTo
StorageIdentifier
Identifies a storage by its ID, name, or alias. At most one may be provided.
{ id }— open a pre-existing storage by its unique ID.{ name }— open or create a globally named storage (persists across runs). The namedefaultis reserved: it resolves to the default storage, and is emptied on start along with it.{ alias }— open or create a run-scoped unnamed storage identified by this alias. The alias is used locally (e.g. as a directory name or cache key) but the storage itself has no persistent name. Use this for non-default unnamed storages. Like the default storage, an aliased one is emptied on start unlesspurgeOnStartis disabled.{}/ omitted — open the default storage.
StorageTransactionState
StorageWriteMode
Governs whether writes of a given storage type performed inside a StorageTransaction are
applied immediately (writeThrough) or recorded and replayed on commit (deferred).
SyncStateConversion
A StateConversion for a caller that cannot await one - Statistics, whose toJSON() is
synchronous, being the reason this exists.
Only the function arm can be narrowed here: a Standard Schema is free to validate asynchronously, so a schema that does is rejected when it runs rather than when it is passed.
Type parameters
- TFrom
- TTo
constcoerceBoolean
Zod preprocessor treating '0' and 'false' as falsy.
constcoerceNumber
constcrawleeConfigFields
Type declaration
availableMemoryRatio: ConfigField<ZodDefault<ZodPreprocess<ZodNumber, unknown>>>
chromeExecutablePath: ConfigField<ZodOptional<ZodString>>
containerized: ConfigField<ZodOptional<ZodPreprocess<ZodBoolean, unknown>>>
defaultBrowserPath: ConfigField<ZodOptional<ZodString>>
defaultDatasetId: ConfigField<ZodDefault<ZodString>>
defaultKeyValueStoreId: ConfigField<ZodDefault<ZodString>>
defaultRequestQueueId: ConfigField<ZodDefault<ZodString>>
disableBrowserSandbox: ConfigField<ZodDefault<ZodPreprocess<ZodBoolean, unknown>>>
headless: ConfigField<ZodDefault<ZodPreprocess<ZodBoolean, unknown>>>
inputKey: ConfigField<ZodDefault<ZodString>>
internalTimeoutMillis: ConfigField<ZodOptional<ZodPreprocess<ZodNumber, unknown>>>
Internal safety-net timeout for a single request, in milliseconds. When unset the crawler derives it from the request handler timeout (twice it, and never below 5 minutes).
logLevel: ConfigField<ZodOptional<ZodPreprocess<ZodEnum<typeof LogLevel>, unknown>>>
maxUsedCpuRatio: ConfigField<ZodDefault<ZodPreprocess<ZodNumber, unknown>>>
memoryMbytes: ConfigField<ZodOptional<ZodPreprocess<ZodNumber, unknown>>>
persistStateIntervalMillis: ConfigField<ZodDefault<ZodPreprocess<ZodNumber, unknown>>>
persistStorage: ConfigField<ZodDefault<ZodPreprocess<ZodBoolean, unknown>>>
purgeOnStart: ConfigField<ZodDefault<ZodPreprocess<ZodBoolean, unknown>>>
storageDir: ConfigField<ZodDefault<ZodString>>
systemInfoIntervalMillis: ConfigField<ZodDefault<ZodPreprocess<ZodNumber, unknown>>>
xvfb: ConfigField<ZodDefault<ZodPreprocess<ZodBoolean, unknown>>>