Skip to main content

apify-client-python

Index

Async Resource Clients

Classes

Data structures

Errors

Methods

Properties

Async Resource Clients

retry_with_exp_backoff_async

  • async retry_with_exp_backoff_async(async_func, *, max_retries, backoff_base_millis, backoff_factor, random_factor): T
  • Parameters

    • async_func: Callable[[StopRetryingType, int], Awaitable[T]]
    • optionalkeyword-onlymax_retries: int = 8
    • optionalkeyword-onlybackoff_base_millis: int = 500
    • optionalkeyword-onlybackoff_factor: float = 2
    • optionalkeyword-onlyrandom_factor: float = 1

    Returns T

Methods

catch_not_found_or_throw

  • catch_not_found_or_throw(exc): None

create_redirect_logger

  • create_redirect_logger(name): logging.Logger
  • Create a logger for redirecting logs from another Actor.


    Parameters

    • name: str

      The name of the logger. It can be used to inherit from other loggers. Example: apify.xyz will use logger named xyz and make it a children of apify logger.

    Returns logging.Logger

encode_key_value_store_record_value

  • encode_key_value_store_record_value(value, content_type): tuple[Any, str]
  • Parameters

    • value: Any
    • optionalcontent_type: str | None = None

    Returns tuple[Any, str]

encode_webhook_list_to_base64

  • encode_webhook_list_to_base64(webhooks): str
  • Encode a list of dictionaries representing webhooks to their base64-encoded representation for the API.


    Parameters

    • webhooks: list[dict]

    Returns str

filter_out_none_values_recursively

  • filter_out_none_values_recursively(dictionary): dict
  • Return copy of the dictionary, recursively omitting all keys for which values are None.


    Parameters

    • dictionary: dict

    Returns dict

filter_out_none_values_recursively_internal

  • filter_out_none_values_recursively_internal(dictionary, *, remove_empty_dicts): dict | None
  • Recursively filters out None values from a dictionary.

    Unfortunately, it's necessary to have an internal function for the correct result typing, without having to create complicated overloads


    Parameters

    • dictionary: dict
    • optionalkeyword-onlyremove_empty_dicts: bool | None = None

    Returns dict | None

get_actor_env_var_representation

  • get_actor_env_var_representation(*, is_secret, name, value): dict
  • Return an environment variable representation of the Actor in a dictionary.


    Parameters

    • optionalkeyword-onlyis_secret: bool | None = None
    • optionalkeyword-onlyname: str | None = None
    • optionalkeyword-onlyvalue: str | None = None

    Returns dict

get_actor_representation

  • get_actor_representation(*, name, title, description, seo_title, seo_description, versions, restart_on_error, is_public, is_deprecated, is_anonymously_runnable, categories, default_run_build, default_run_max_items, default_run_memory_mbytes, default_run_timeout_secs, example_run_input_body, example_run_input_content_type, actor_standby_is_enabled, actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run, actor_standby_idle_timeout_secs, actor_standby_build, actor_standby_memory_mbytes, pricing_infos): dict
  • Get dictionary representation of the Actor.


    Parameters

    • keyword-onlyname: str | None
    • optionalkeyword-onlytitle: str | None = None
    • optionalkeyword-onlydescription: str | None = None
    • optionalkeyword-onlyseo_title: str | None = None
    • optionalkeyword-onlyseo_description: str | None = None
    • optionalkeyword-onlyversions: list[dict] | None = None
    • optionalkeyword-onlyrestart_on_error: bool | None = None
    • optionalkeyword-onlyis_public: bool | None = None
    • optionalkeyword-onlyis_deprecated: bool | None = None
    • optionalkeyword-onlyis_anonymously_runnable: bool | None = None
    • optionalkeyword-onlycategories: list[str] | None = None
    • optionalkeyword-onlydefault_run_build: str | None = None
    • optionalkeyword-onlydefault_run_max_items: int | None = None
    • optionalkeyword-onlydefault_run_memory_mbytes: int | None = None
    • optionalkeyword-onlydefault_run_timeout_secs: int | None = None
    • optionalkeyword-onlyexample_run_input_body: Any = None
    • optionalkeyword-onlyexample_run_input_content_type: str | None = None
    • optionalkeyword-onlyactor_standby_is_enabled: bool | None = None
    • optionalkeyword-onlyactor_standby_desired_requests_per_actor_run: int | None = None
    • optionalkeyword-onlyactor_standby_max_requests_per_actor_run: int | None = None
    • optionalkeyword-onlyactor_standby_idle_timeout_secs: int | None = None
    • optionalkeyword-onlyactor_standby_build: str | None = None
    • optionalkeyword-onlyactor_standby_memory_mbytes: int | None = None
    • optionalkeyword-onlypricing_infos: list[dict] | None = None

    Returns dict

get_task_representation

  • get_task_representation(actor_id, name, task_input, build, max_items, memory_mbytes, timeout_secs, title, actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run, actor_standby_idle_timeout_secs, actor_standby_build, actor_standby_memory_mbytes): dict
  • Get the dictionary representation of a task.


    Parameters

    • optionalactor_id: str | None = None
    • optionalname: str | None = None
    • optionaltask_input: dict | None = None
    • optionalbuild: str | None = None
    • optionalmax_items: int | None = None
    • optionalmemory_mbytes: int | None = None
    • optionaltimeout_secs: int | None = None
    • optionaltitle: str | None = None
    • optionalactor_standby_desired_requests_per_actor_run: int | None = None
    • optionalactor_standby_max_requests_per_actor_run: int | None = None
    • optionalactor_standby_idle_timeout_secs: int | None = None
    • optionalactor_standby_build: str | None = None
    • optionalactor_standby_memory_mbytes: int | None = None

    Returns dict

get_webhook_representation

  • get_webhook_representation(*, event_types, request_url, payload_template, headers_template, actor_id, actor_task_id, actor_run_id, ignore_ssl_errors, do_not_retry, idempotency_key, is_ad_hoc): dict
  • Prepare webhook dictionary representation for clients.


    Parameters

    • optionalkeyword-onlyevent_types: list[WebhookEventType] | None = None
    • optionalkeyword-onlyrequest_url: str | None = None
    • optionalkeyword-onlypayload_template: str | None = None
    • optionalkeyword-onlyheaders_template: str | None = None
    • optionalkeyword-onlyactor_id: str | None = None
    • optionalkeyword-onlyactor_task_id: str | None = None
    • optionalkeyword-onlyactor_run_id: str | None = None
    • optionalkeyword-onlyignore_ssl_errors: bool | None = None
    • optionalkeyword-onlydo_not_retry: bool | None = None
    • optionalkeyword-onlyidempotency_key: str | None = None
    • optionalkeyword-onlyis_ad_hoc: bool | None = None

    Returns dict

is_content_type_json

  • is_content_type_json(content_type): bool
  • Check if the given content type is JSON.


    Parameters

    • content_type: str

    Returns bool

is_content_type_text

  • is_content_type_text(content_type): bool
  • Check if the given content type is text.


    Parameters

    • content_type: str

    Returns bool

is_content_type_xml

  • is_content_type_xml(content_type): bool
  • Check if the given content type is XML.


    Parameters

    • content_type: str

    Returns bool

is_file_or_bytes

  • is_file_or_bytes(value): bool
  • Check if the input value is a file-like object or bytes.

    The check for IOBase is not ideal, it would be better to use duck typing, but then the check would be super complex, judging from how the 'requests' library does it. This way should be good enough for the vast majority of use cases, if it causes issues, we can improve it later.


    Parameters

    • value: Any

    Returns bool

is_retryable_error

  • is_retryable_error(exc): bool
  • Check if the given error is retryable.


    Parameters

    • exc: Exception

    Returns bool

json_dumps

  • json_dumps(obj): str
  • Dump JSON to a string with the correct settings and serializer.


    Parameters

    • obj: Any

    Returns str

maybe_extract_enum_member_value

  • maybe_extract_enum_member_value(maybe_enum_member): Any
  • Extract the value of an enumeration member if it is an Enum, otherwise return the original value.


    Parameters

    • maybe_enum_member: Any

    Returns Any

maybe_parse_response

  • maybe_parse_response(response): Any
  • Parameters

    • response: Response

    Returns Any

parse_date_fields

  • Recursively parse date fields in a list or dictionary up to the specified depth.


    Parameters

    • data: ListOrDict
    • optionalmax_depth: int = PARSE_DATE_FIELDS_MAX_DEPTH

    Returns ListOrDict

pluck_data

  • pluck_data(parsed_response): dict
  • Parameters

    • parsed_response: Any

    Returns dict

pluck_data_as_list

  • pluck_data_as_list(parsed_response): list
  • Parameters

    • parsed_response: Any

    Returns list

retry_with_exp_backoff

  • retry_with_exp_backoff(func, *, max_retries, backoff_base_millis, backoff_factor, random_factor): T
  • Parameters

    • func: Callable[[StopRetryingType, int], T]
    • optionalkeyword-onlymax_retries: int = 8
    • optionalkeyword-onlybackoff_base_millis: int = 500
    • optionalkeyword-onlybackoff_factor: float = 2
    • optionalkeyword-onlyrandom_factor: float = 1

    Returns T

to_safe_id

  • to_safe_id(id): str
  • Parameters

    • id: str

    Returns str

Properties

__version__

__version__: Undefined

API_VERSION

API_VERSION: Undefined

DEFAULT_API_URL

DEFAULT_API_URL: Undefined

DEFAULT_BACKOFF_EXPONENTIAL_FACTOR

DEFAULT_BACKOFF_EXPONENTIAL_FACTOR: Undefined

DEFAULT_BACKOFF_RANDOM_FACTOR

DEFAULT_BACKOFF_RANDOM_FACTOR: Undefined

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT: Undefined

DEFAULT_WAIT_FOR_FINISH_SEC

DEFAULT_WAIT_FOR_FINISH_SEC: Undefined

DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC

DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC: Undefined

JSONSerializable

JSONSerializable: Undefined

Type for representing json-serializable values. It's close enough to the real thing supported by json.parse, and the best we can do until mypy supports recursive types. It was suggested in a discussion with (and approved by) Guido van Rossum, so I'd consider it correct enough.

ListOrDict

ListOrDict: Undefined

log_context

log_context: Undefined

logger

logger: Undefined

logger

logger: Undefined

logger

logger: Undefined

logger_name

logger_name: Undefined

PARSE_DATE_FIELDS_KEY_SUFFIX

PARSE_DATE_FIELDS_KEY_SUFFIX: Undefined

PARSE_DATE_FIELDS_MAX_DEPTH

PARSE_DATE_FIELDS_MAX_DEPTH: Undefined

RECORD_NOT_FOUND_EXCEPTION_TYPES

RECORD_NOT_FOUND_EXCEPTION_TYPES: Undefined

StopRetryingType

StopRetryingType: Undefined

T

T: Undefined

T

T: Undefined

T

T: Undefined