@@ -64,6 +64,7 @@ def __init__(
6464 token : str | None = None ,
6565 * ,
6666 api_url : str | None = None ,
67+ api_public_url : str | None = None ,
6768 max_retries : int | None = 8 ,
6869 min_delay_between_retries_millis : int | None = 500 ,
6970 timeout_secs : int | None = DEFAULT_TIMEOUT ,
@@ -72,7 +73,10 @@ def __init__(
7273
7374 Args:
7475 token: The Apify API token.
75- api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com.
76+ api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. It can
77+ be internal url that is not globally accessible, in such case `api_public_url` should be set as well.
78+ api_public_url: The globally accessible URL of the Apify API server. It should be set only if the `api_url`
79+ is internal url that is not globally accessible.
7680 max_retries: How many times to retry a failed request at most.
7781 min_delay_between_retries_millis: How long will the client wait between retrying requests
7882 (increases exponentially from this value).
@@ -81,6 +85,7 @@ def __init__(
8185 self .token = token
8286 api_url = (api_url or DEFAULT_API_URL ).rstrip ('/' )
8387 self .base_url = f'{ api_url } /{ API_VERSION } '
88+ self .public_base_url = (api_public_url or self .base_url ).rstrip ('/' )
8489 self .max_retries = max_retries or 8
8590 self .min_delay_between_retries_millis = min_delay_between_retries_millis or 500
8691 self .timeout_secs = timeout_secs or DEFAULT_TIMEOUT
@@ -103,6 +108,7 @@ def __init__(
103108 token : str | None = None ,
104109 * ,
105110 api_url : str | None = None ,
111+ api_public_url : str | None = None ,
106112 max_retries : int | None = 8 ,
107113 min_delay_between_retries_millis : int | None = 500 ,
108114 timeout_secs : int | None = DEFAULT_TIMEOUT ,
@@ -111,7 +117,10 @@ def __init__(
111117
112118 Args:
113119 token: The Apify API token.
114- api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com.
120+ api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. It can
121+ be internal url that is not globally accessible, in such case `api_public_url` should be set as well.
122+ api_public_url: The globally accessible URL of the Apify API server. It should be set only if the `api_url`
123+ is internal url that is not globally accessible.
115124 max_retries: How many times to retry a failed request at most.
116125 min_delay_between_retries_millis: How long will the client wait between retrying requests
117126 (increases exponentially from this value).
@@ -120,6 +129,7 @@ def __init__(
120129 super ().__init__ (
121130 token ,
122131 api_url = api_url ,
132+ api_public_url = api_public_url ,
123133 max_retries = max_retries ,
124134 min_delay_between_retries_millis = min_delay_between_retries_millis ,
125135 timeout_secs = timeout_secs ,
@@ -286,6 +296,7 @@ def __init__(
286296 token : str | None = None ,
287297 * ,
288298 api_url : str | None = None ,
299+ api_public_url : str | None = None ,
289300 max_retries : int | None = 8 ,
290301 min_delay_between_retries_millis : int | None = 500 ,
291302 timeout_secs : int | None = DEFAULT_TIMEOUT ,
@@ -294,7 +305,10 @@ def __init__(
294305
295306 Args:
296307 token: The Apify API token.
297- api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com.
308+ api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. It can
309+ be internal url that is not globally accessible, in such case `api_public_url` should be set as well.
310+ api_public_url: The globally accessible URL of the Apify API server. It should be set only if the `api_url`
311+ is internal url that is not globally accessible.
298312 max_retries: How many times to retry a failed request at most.
299313 min_delay_between_retries_millis: How long will the client wait between retrying requests
300314 (increases exponentially from this value).
@@ -303,6 +317,7 @@ def __init__(
303317 super ().__init__ (
304318 token ,
305319 api_url = api_url ,
320+ api_public_url = api_public_url ,
306321 max_retries = max_retries ,
307322 min_delay_between_retries_millis = min_delay_between_retries_millis ,
308323 timeout_secs = timeout_secs ,
0 commit comments