Skip to content

feat: add a user_agent_suffix option - #1145

Merged
vdusek merged 1 commit into
masterfrom
feat/user-agent-suffix
Oct 16, 2026
Merged

vdusek merged 1 commit into
masterfrom
feat/user-agent-suffix

Conversation

@vdusek

@vdusek vdusek commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds user_agent_suffix to ApifyClient, ApifyClientAsync and the built-in HTTP clients, so tools built on top of the client can identify themselves. It takes a string or a list of strings and appends them to the default User-Agent after ; , the same format as the JS client's userAgentSuffix. With with_custom_http_client, pass it to the HTTP client's constructor.

Closes: #1148

✍️ Drafted by Claude Code

@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 Oct 16, 2026
@vdusek vdusek self-assigned this Oct 16, 2026
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.47%. Comparing base (53a9954) to head (ae8365c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
+ Coverage   95.43%   95.47%   +0.03%     
==========================================
  Files          61       61              
  Lines        5935     5940       +5     
==========================================
+ Hits         5664     5671       +7     
+ Misses        271      269       -2     
Flag Coverage Δ
integration 91.04% <60.00%> (+0.24%) ⬆️
unit 88.88% <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.

@vdusek
vdusek marked this pull request as ready for review October 16, 2026 11:56
@vdusek
vdusek requested a review from szaganek as a code owner October 16, 2026 11:56
@vdusek
vdusek requested review from Mantisus and Pijukatel and removed request for szaganek October 16, 2026 11:56
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 16, 2026
@vdusek vdusek removed the adhoc Ad-hoc unplanned task added during the sprint. label Oct 16, 2026

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, if we are going to use it ourselves

user_agent_suffix_cases = [
pytest.param(None, '', id='no suffix'),
pytest.param('MyTool/1.0', '; MyTool/1.0', id='string suffix'),
pytest.param(['SDK/3.0.0', 'Crawlee/1.0.0'], '; SDK/3.0.0; Crawlee/1.0.0', id='list suffix'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a test, or a hint that we are going to set those suffixes in our tools built on top of the client?

@vdusek vdusek Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We surely can.

In JS, SDK and the MCP server use it. The SDK sets SDK/<version> and Crawlee/<version>.

In Python, the LangChain and Haystack integrations do the same, but through client internals. LangChain uses client.http_client._headers and Haystack uses client.http_client.httpx_client. Strands sends its own custom x-apify-integration-platform header.

@apify-approval-mirror apify-approval-mirror Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirroring approval from @Mantisus.

@vdusek
vdusek merged commit ecccadb into master Oct 16, 2026
40 of 41 checks passed
@vdusek
vdusek deleted the feat/user-agent-suffix branch October 16, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a user_agent_suffix option

4 participants