Skip to content

refactor: Consolidate public interface for v3#794

Open
vdusek wants to merge 1 commit into
masterfrom
refactor/v3-shrink-public-api
Open

refactor: Consolidate public interface for v3#794
vdusek wants to merge 1 commit into
masterfrom
refactor/v3-shrink-public-api

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented May 15, 2026

Description

Consolidates the public interface for the v3 release:

  • Root apify_client namespace now only exposes ApifyClient, ApifyClientAsync, and __version__. This is a go-to for everyone.
  • HTTP client abstractions moved to http_clients submodule (HttpClient, HttpClientAsync, HttpResponse, ImpitHttpClient, ImpitHttpClientAsync). Only for people who want to replace the default HTTP client.
  • New public types.py module with Timeout, WebhooksList, and JsonSerializable type aliases (can be used, e.g., for a custom HTTP client).
  • Add missing __all__ to errors.py.
  • Update v3 upgrade guide and doc snippets to reflect new import paths.
  • Not breaking, because HTTP clients were not part of v2.5.

I would prefer to keep _models and _typeddicts private. They should not be considered safe to import, since exposing them publicly would potentially restrict future API changes. For typed dicts, users do not need to import them to pass inputs to resource client methods. Resource clients, which are also private and users should be able to get to them only via ApifyClient (and its async version), may return Pydantic models, but those models should not be constructed directly in user code. There may be niche cases where users want to import models or typed dicts for explicit typing or casts, but I would rather keep those available only on the user's own responsibility - we cannot guarantee that the types will not change. This is also a status quo in the current v2.5.

This is my stand, let me know yours @janbuchar.

Issue

Closes: #744

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels May 15, 2026
@vdusek vdusek self-assigned this May 15, 2026
@github-actions github-actions Bot added this to the 140th sprint - Tooling team milestone May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.94%. Comparing base (d1bd5a3) to head (ea60c97).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/apify_client/types.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #794      +/-   ##
==========================================
- Coverage   97.73%   95.94%   -1.80%     
==========================================
  Files          48       48              
  Lines        4860     4859       -1     
==========================================
- Hits         4750     4662      -88     
- Misses        110      197      +87     
Flag Coverage Δ
integration 92.17% <87.50%> (-1.49%) ⬇️
unit 84.27% <87.50%> (-1.92%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@vdusek vdusek changed the title refactor: shrink public API surface for v3 refactor: Consolidate public interface for v3 May 15, 2026
@vdusek vdusek requested a review from janbuchar May 15, 2026 12:05
@vdusek vdusek marked this pull request as ready for review May 15, 2026 12:06
@janbuchar
Copy link
Copy Markdown
Contributor

I'm not sure if apify_client.types is actually necessary to develop a new Client, but otherwise I completely agree with the changes, thanks, well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revise public interface of types before v3 release

3 participants