Skip to content

feat: support APIFY_API_BASE_URL and APIFY_API_PUBLIC_BASE_URL env vars#948

Closed
Pijukatel wants to merge 2 commits into
masterfrom
claude/api-console-env-vars-nel6s3
Closed

feat: support APIFY_API_BASE_URL and APIFY_API_PUBLIC_BASE_URL env vars#948
Pijukatel wants to merge 2 commits into
masterfrom
claude/api-console-env-vars-nel6s3

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

The API base URL and public API base URL could only be set through constructor arguments, so pointing the client at a local platform, a staging deployment, or a custom host/port meant threading arguments through every construction site.

Both URLs now resolve as explicit argument > environment variable > default constant:

  • APIFY_API_BASE_URLapi_url
  • APIFY_API_PUBLIC_BASE_URLapi_public_url

The two variables are independent (each keeps its own default). Empty-string env values are treated as unset. The resolution is applied identically in the sync ApifyClient, the async ApifyClientAsync, and the with_custom_http_client path, and the automatic /v2 suffixing is unchanged. Setting nothing reproduces today's behavior exactly.

Context

This is one of three sibling PRs applying the same env-var contract across the Apify clients and CLI (the CLI also adds APIFY_CONSOLE_BASE_URL). Separate repos, no overlapping files:

What we're solving: the API base URL and public API base URL could only be set
via constructor arguments, so pointing the client at a local, staging, or
custom-port deployment meant threading arguments through every call site.

How: both URLs now resolve as explicit argument > environment variable >
default constant, applied identically in the sync and async clients and the
with_custom_http_client path. Empty-string env values are treated as unset and
the /v2 suffixing is unchanged, so setting nothing behaves exactly as before.

Alternatives considered: a shared cross-repo config package, rejected as
unnecessary for two values with a single construction site per client.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bXf84xVdv32VQAt916Ygj
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.52%. Comparing base (dbd39d0) to head (ab23a55).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #948      +/-   ##
==========================================
- Coverage   94.56%   94.52%   -0.05%     
==========================================
  Files          48       48              
  Lines        5119     5133      +14     
==========================================
+ Hits         4841     4852      +11     
- Misses        278      281       +3     
Flag Coverage Δ
integration 92.57% <100.00%> (-0.39%) ⬇️
unit 83.44% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Collapse the per-case sync/async base-URL resolution tests into
pytest.mark.parametrize cases with descriptive ids, covering the same
behavior (and a little more, since sync and async now share every case).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bXf84xVdv32VQAt916Ygj
@Pijukatel

Copy link
Copy Markdown
Contributor Author

Close in favor of smaller CLI update: apify/apify-cli#1276

@Pijukatel Pijukatel closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants