Skip to content

docs(examples): add coinbase-examples-nodejs.md (one page of copy-ready snippets) - #167

Open
harbourlark wants to merge 1 commit into
sieblyio:masterfrom
harbourlark:docs/examples-markdown
Open

harbourlark wants to merge 1 commit into
sieblyio:masterfrom
harbourlark:docs/examples-markdown

Conversation

@harbourlark

Copy link
Copy Markdown

Adds examples/coinbase-examples-nodejs.md, a single page of short, copy-ready snippets in the same style as kucoin-api/examples/kucoin-*-examples-nodejs.md and the new examples pages for hyperliquid-api (sieblyio/hyperliquid-api#19), kraken-api (sieblyio/kraken-api#71) and gateio-api.

Why: Context7 parses markdown, and its benchmark for /sieblyio/coinbase-api is 52.5 (last indexed 11 Nov), below kucoin-api (73.88) and okx-api (75.78). The runnable .ts examples and examples/apidoc stay as they are; this page gives indexers and readers one place to find each task.

Covers: which client to use (Advanced Trade, App, Exchange, International, Prime, Commerce, WebSocket and WS API clients), client setup (public, CDP keys with ECDSA or Ed25519, one-line PEM env vars, CommonJS), Advanced Trade market data (server time, products and increments, order book, candles, recent trades), account (paginated accounts, best bid/ask, key permissions, open orders and fills), trading (preview, post-only limit with client_order_id, market order in quote size, stop-limit, get/edit/cancel), Coinbase App spot price and rates, Coinbase Exchange public data and private client, WebSockets (public and private Advanced Trade, the Exchange feed that replaced the Coinbase Pro feed, unsubscribe and close) and error handling.

Checked against coinbase-api 1.3.2:

  • All 25 TypeScript snippets compile as standalone files under tsc --strict (module nodenext); the CommonJS one ran under Node.
  • Every public REST snippet (Advanced Trade, App, Exchange) and the public WebSocket snippets (advTradeMarketData ticker, market_trades, level2, heartbeats; exchangeMarketData ticker and matches) ran live, as did unsubscribe/closeAll.
  • Private snippets were exercised with a throwaway ECDSA key only (REST answered 401, the user WebSocket answered "authentication failure"), so no orders were placed. The error handling snippet was run against that 401 and confirms keys show as omittedFromError.
  • Prices in the trading snippets are far from market and sizes are small.

Small thing noticed while testing: CBAppClient.getSpotPrice (and getBuyPrice/getSellPrice) return data.base (for example "BTC"), but the response type only declares amount and currency, so data.base fails under tsc --strict. The page avoids it for now.

This branch has not been deployed

No deployments
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.

1 participant