Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.

feat(foxbit): add X-FB-CLIENT identification headers - #11

Open
matheus-alcuri-foxbit wants to merge 2 commits into
masterfrom
ccxt-client-identification
Open

feat(foxbit): add X-FB-CLIENT identification headers#11
matheus-alcuri-foxbit wants to merge 2 commits into
masterfrom
ccxt-client-identification

Conversation

@matheus-alcuri-foxbit

Copy link
Copy Markdown

Summary

Sends X-FB-CLIENT: ccxt and X-FB-CLIENT-VERSION: <ccxt version> on every foxbit REST request so the exchange can identify and measure ccxt-originated traffic (client header approach chosen over User-Agent, which users/base code can override).

Since the library version constant was not reachable from transpiled exchange code, this adds a getCcxtVersion() base helper implemented above the transpile marker (hand-written per language: TS/JS, Python, PHP, C#, Go). Headers are injected in sign() (same pattern as bybit's Referer), so they take precedence over user headers overrides. A testFoxbit broker-id test asserts both headers via last_request_headers in all five languages.

Related: foxbit-group/kepler#2902 (server-side metric), foxbit-group/ccxt-foxbit-tests#18 (E2E tests).

Tests run

  • npm run lint — pass (0 errors on edited files)
  • npm run tsBuild — pass
  • npm run transpile (Python + PHP) — pass
  • npm run transpileCS + npm run buildCS — pass (dotnet 9, 4 projects, 0 errors)
  • npm run transpileGO + npm run buildGO — pass (v4 + v4/pro)
  • request tests — 70 passed in JS, Python, PHP, C#, Go
  • response tests — 17 passed in JS, Python, PHP, C#, Go
  • id-tests (brokerId suite incl. new testFoxbit) — passed in JS, Python, PHP, C#, Go
  • test-base-rest — passed in JS and Python (base was touched)
  • Python syntax via py_compile; PHP via php -l (php:8.2 container)
  • Live smoke: fetchTicker BTC/BRL against api.foxbit.com.br — request carried both headers, 200 OK

Notes

  • Diff is source-only: ts/src/** + hand-written base files (python/ccxt/base/exchange.py, php/Exchange.php, cs/ccxt/base/Exchange.Misc.cs, go/v4/exchange_metadata.go, go/v4/exchange_interface.go). Per-exchange generated files are left to the build automation.
  • The version header value comes from each language's existing version constant (__version__, Exchange::VERSION, ccxtVersion, Version), all already bumped by vss.
  • Follow-up: upstream this to ccxt/ccxt so the headers ship in released packages — real traffic only carries them once users update.

🤖 Generated with Claude Code

Send X-FB-CLIENT: ccxt and X-FB-CLIENT-VERSION: <ccxt version> on every
foxbit REST request so the exchange can identify ccxt-originated traffic.

Adds a getCcxtVersion() base helper (hand-written in each language, above
the transpile marker) since the library version constant was not reachable
from transpiled exchange code, and a testFoxbit broker-id test asserting
both headers via last_request_headers in all five languages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Adds Foxbit-specific client identification headers to all REST requests, enabling the exchange to attribute CCXT traffic, and introduces a small cross-language base helper to expose the library version for that header value.

Changes:

  • Injects X-FB-CLIENT: ccxt and X-FB-CLIENT-VERSION: <ccxt version> in foxbit REST request signing.
  • Adds a getCcxtVersion()/get_ccxt_version() helper across the base classes in TS + transpiled languages.
  • Extends the brokerId test suite with an offline testFoxbit assertion that validates both headers via last_request_headers.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ts/src/test/tests.ts Adds testFoxbit() to the brokerId suite and asserts the two Foxbit headers from last_request_headers.
ts/src/foxbit.ts Adds Foxbit client identification headers in sign() for all REST requests.
ts/src/base/Exchange.ts Introduces getCcxtVersion() in the TS base exchange class (used by foxbit.sign()).
python/ccxt/base/exchange.py Adds get_ccxt_version() returning __version__ for Python runtime parity.
php/Exchange.php Adds get_ccxt_version() returning static::VERSION for PHP runtime parity.
cs/ccxt/base/Exchange.Misc.cs Adds getCcxtVersion() returning ccxtVersion for C# runtime parity.
go/v4/exchange_metadata.go Adds GetCcxtVersion() returning Version for Go runtime parity.
go/v4/exchange_interface.go Adds GetCcxtVersion() to ICoreExchange so Go callers/tests can access it uniformly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ts/src/base/Exchange.ts
Addresses Copilot review on the PR: the JSDoc promised a semver string
but the JS implementation returns "unknown" when Exchange.ccxtVersion
is not initialized (direct module import bypassing the entry point).
The fallback is intentional; the doc now states it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants