Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion src/apify_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const DEFAULT_TIMEOUT_SECS = 360;
export class ApifyClient {
baseUrl: string;

/**
* @since Added in 2.17.0
*/
publicBaseUrl: string;

token?: string;
Expand Down Expand Up @@ -549,6 +552,7 @@ export class ApifyClient {
* @param message - The status message to set
* @param options - Additional options for the status message
* @throws {Error} If `ACTOR_RUN_ID` environment variable is not set
* @since Added in 2.7.0
*/
async setStatusMessage(message: string, options?: SetStatusMessageOptions): Promise<void> {
const runId = process.env[ACTOR_ENV_VARS.RUN_ID];
Expand All @@ -568,7 +572,10 @@ export class ApifyClient {
export interface ApifyClientOptions {
/** @default https://api.apify.com */
baseUrl?: string;
/** @default https://api.apify.com */
/**
* @default https://api.apify.com
* @since Added in 2.17.0
*/
publicBaseUrl?: string;
/** @default 8 */
maxRetries?: number;
Expand All @@ -579,5 +586,8 @@ export interface ApifyClientOptions {
/** @default 360 */
timeoutSecs?: number;
token?: string;
/**
* @since Added in 2.10.0
*/
userAgentSuffix?: string | string[];
}
3 changes: 3 additions & 0 deletions src/base/api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export abstract class ApiClient {

baseUrl: string;

/**
* @since Added in 2.17.0
*/
publicBaseUrl: string;

resourcePath: string;
Expand Down
107 changes: 100 additions & 7 deletions src/resource_clients/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export class ActorClient extends ResourceClient {
* const buildClient = await client.actor('my-actor').defaultBuild({ waitForFinish: 60 });
* const build = await buildClient.get();
* ```
* @since Added in 2.12.2
*/
async defaultBuild(options: BuildClientGetOptions = {}): Promise<BuildClient> {
const response = await this.httpClient.call({
Expand Down Expand Up @@ -482,7 +483,10 @@ export interface Actor {
stats: ActorStats;
/** All versions of this Actor */
versions: ActorVersion[];
/** Pricing information for pay-per-result or pay-per-event Actors */
/**
* Pricing information for pay-per-result or pay-per-event Actors
* @since Added in 2.12.4
*/
pricingInfos?: ActorRunPricingInfo[];
/** Default configuration options for Actor runs */
defaultRunOptions: ActorDefaultRunOptions;
Expand All @@ -496,19 +500,37 @@ export interface Actor {
title?: string;
/** Mapping of tags to specific builds (e.g., 'latest', 'beta') */
taggedBuilds?: ActorTaggedBuilds;
/** SEO-optimized title for the Actor's public page */
/**
* SEO-optimized title for the Actor's public page
* @since Added in 2.6.1
*/
seoTitle?: string;
/** SEO-optimized description for the Actor's public page */
/**
* SEO-optimized description for the Actor's public page
* @since Added in 2.6.1
*/
seoDescription?: string;
/** Categories the Actor belongs to (e.g., 'ECOMMERCE', 'SCRAPING') */
/**
* Categories the Actor belongs to (e.g., 'ECOMMERCE', 'SCRAPING')
* @since Added in 2.6.1
*/
categories?: string[];
/** Standby mode configuration for keeping Actor warm and responsive */
/**
* Standby mode configuration for keeping Actor warm and responsive
* @since Added in 2.9.5
*/
actorStandby?: ActorStandby & {
isEnabled: boolean;
};
/** Permission level of the Actor on Apify platform */
/**
* Permission level of the Actor on Apify platform
* @since Added in 2.21.0
*/
actorPermissionLevel: ACTOR_PERMISSION_LEVEL;
/** A brief, LLM-generated readme summary */
/**
* A brief, LLM-generated readme summary
* @since Added in 2.22.1
*/
readmeSummary?: string;
}

Expand Down Expand Up @@ -541,6 +563,9 @@ export interface ActorDefaultRunOptions {
build: string;
timeoutSecs: number;
memoryMbytes: number;
/**
* @since Added in 2.19.0
*/
restartOnError?: boolean;
}

Expand Down Expand Up @@ -594,14 +619,21 @@ export type ActorUpdateOptions = Partial<
*
* Standby mode keeps Actor containers warm and ready to process requests with minimal latency.
* This is useful for Actors that need to respond quickly to incoming requests.
* @since Added in 2.9.5
*/
export interface ActorStandby {
build?: string;
desiredRequestsPerActorRun?: number;
/**
* @since Added in 2.22.0
*/
disableStandbyFieldsOverride?: boolean;
idleTimeoutSecs?: number;
maxRequestsPerActorRun?: number;
memoryMbytes?: number;
/**
* @since Added in 2.22.0
*/
shouldPassActorInput?: boolean;
}

Expand Down Expand Up @@ -654,6 +686,7 @@ export interface ActorStartOptions {
* It only ensures you won't be charged for more than this number of items.
* Only works for pay-per-result Actors.
* Value can be accessed in the Actor run using `ACTOR_MAX_PAID_DATASET_ITEMS` environment variable.
* @since Added in 2.7.0
*/
maxItems?: number;

Expand All @@ -662,6 +695,7 @@ export interface ActorStartOptions {
* used only for pay-per-event Actors. It allows you to limit the amount
* charged to your subscription. You can access the maximum cost in your
* Actor by using the `ACTOR_MAX_TOTAL_CHARGE_USD` environment variable.
* @since Added in 2.9.7
*/
maxTotalChargeUsd?: number;

Expand All @@ -675,6 +709,7 @@ export interface ActorStartOptions {
/**
* Override the Actor's permissions for this run. If not set, the Actor will run with permissions configured in the
* Actor settings.
* @since Added in 2.17.0
*/
forcePermissionLevel?: ACTOR_PERMISSION_LEVEL;
}
Expand All @@ -683,6 +718,7 @@ export interface ActorStartOptions {
* Options for calling an Actor and waiting for it to finish.
*
* Extends {@link ActorStartOptions} with additional options for waiting and log streaming.
* @since Added in 2.6.2
*/
export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish'> {
/**
Expand All @@ -693,6 +729,7 @@ export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish
* `Log` instance that should be used to redirect Actor run logs to.
* If `undefined` or `'default'` the pre-defined `Log` will be created and used.
* If `null`, no log redirection will occur.
* @since Added in 2.20.0
*/
log?: Log | null | 'default';
}
Expand All @@ -701,6 +738,7 @@ export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish
* Simplified Actor run information used in list results.
*
* Contains basic information about a run without detailed statistics.
* @since Added in 2.7.0
*/
export interface ActorRunListItem {
id: string;
Expand All @@ -714,10 +752,19 @@ export interface ActorRunListItem {
buildNumber: string;
defaultKeyValueStoreId: string;
defaultDatasetId: string;
/**
* @since Added in 2.6.1
*/
defaultRequestQueueId: string;
/**
* @since Added in 2.7.2
*/
usageTotalUsd?: number;
}

/**
* @since Added in 2.22.3
*/
export interface ActorRunStorageIds {
/** Aliased dataset IDs for this run. */
datasets: { default: string; [alias: string]: string };
Expand All @@ -735,25 +782,53 @@ export interface ActorRunStorageIds {
*/
export interface ActorRun extends ActorRunListItem {
userId: string;
/**
* @since Added in 2.6.0
*/
statusMessage?: string;
stats: ActorRunStats;
options: ActorRunOptions;
exitCode?: number;
containerUrl: string;
/**
* @since Added in 2.7.0
*/
isContainerServerReady?: boolean;
/**
* @since Added in 2.7.0
*/
gitBranchName?: string;
/**
* @since Added in 2.7.0
*/
usage?: ActorRunUsage;
/**
* @since Added in 2.7.2
*/
usageUsd?: ActorRunUsage;
/**
* @since Added in 2.11.1
*/
pricingInfo?: ActorRunPricingInfo;
/**
* @since Added in 2.11.1
*/
chargedEventCounts?: Record<string, number>;
/**
* @since Added in 2.12.2
*/
generalAccess?: RUN_GENERAL_ACCESS | null;
/**
* @since Added in 2.22.3
*/
storageIds?: ActorRunStorageIds;
}

/**
* Resource usage metrics for an Actor run.
*
* All values represent the total consumption during the run's lifetime.
* @since Added in 2.7.0
*/
export interface ActorRunUsage {
/** Compute units consumed (combines CPU and memory usage over time) */
Expand Down Expand Up @@ -824,8 +899,17 @@ export interface ActorRunOptions {
timeoutSecs: number;
memoryMbytes: number;
diskMbytes: number;
/**
* @since Added in 2.20.0
*/
maxItems?: number;
/**
* @since Added in 2.11.1
*/
maxTotalChargeUsd?: number;
/**
* @since Added in 2.19.0
*/
restartOnError?: boolean;
}

Expand All @@ -851,6 +935,7 @@ export interface ActorLastRunOptions {
*
* Contains the Actor's configuration, input schema, and other metadata.
* @see https://docs.apify.com/platform/actors/development/actor-definition/actor-json
* @since Added in 2.11.0
*/
export interface ActorDefinition {
actorSpecification: number;
Expand All @@ -869,6 +954,7 @@ export interface ActorDefinition {
/**
* Output schema for the Actor.
* @see https://docs.apify.com/platform/actors/development/actor-definition/output-schema
* @since Added in 2.23.0
*/
output?: object | null;
changelog?: string | null;
Expand All @@ -894,13 +980,15 @@ interface CommonActorPricingInfo {

/**
* Pricing information for free Actors.
* @since Added in 2.11.1
*/
export interface FreeActorPricingInfo extends CommonActorPricingInfo {
pricingModel: 'FREE';
}

/**
* Pricing information for Actors with a flat monthly subscription fee.
* @since Added in 2.11.1
*/
export interface FlatPricePerMonthActorPricingInfo extends CommonActorPricingInfo {
pricingModel: 'FLAT_PRICE_PER_MONTH';
Expand All @@ -914,6 +1002,7 @@ export interface FlatPricePerMonthActorPricingInfo extends CommonActorPricingInf
* Pricing information for pay-per-result Actors.
*
* These Actors charge based on the number of items saved to the dataset.
* @since Added in 2.11.1
*/
export interface PricePerDatasetItemActorPricingInfo extends CommonActorPricingInfo {
pricingModel: 'PRICE_PER_DATASET_ITEM';
Expand All @@ -924,6 +1013,7 @@ export interface PricePerDatasetItemActorPricingInfo extends CommonActorPricingI

/**
* Definition of a chargeable event for pay-per-event Actors.
* @since Added in 2.11.1
*/
export interface ActorChargeEvent {
eventPriceUsd: number;
Expand All @@ -933,13 +1023,15 @@ export interface ActorChargeEvent {

/**
* Mapping of event names to their pricing information.
* @since Added in 2.11.1
*/
export type ActorChargeEvents = Record<string, ActorChargeEvent>;

/**
* Pricing information for pay-per-event Actors.
*
* These Actors charge based on specific events (e.g., emails sent, API calls made).
* @since Added in 2.11.1
*/
export interface PricePerEventActorPricingInfo extends CommonActorPricingInfo {
pricingModel: 'PAY_PER_EVENT';
Expand All @@ -951,6 +1043,7 @@ export interface PricePerEventActorPricingInfo extends CommonActorPricingInfo {

/**
* Union type representing all possible Actor pricing models.
* @since Added in 2.11.1
*/
export type ActorRunPricingInfo =
| PricePerEventActorPricingInfo
Expand Down
Loading
Loading