Add examples/ folder with runnable usage scripts#8
Merged
pimfeltkamp merged 2 commits intomainfrom Apr 28, 2026
Merged
Conversation
Five self-contained TypeScript examples covering the most common usage patterns: a public unauthenticated ticker fetch, an authenticated whoami, listing hoppers with optional filter, the typed CryptohopperError surface, and a 30-day backtest with polling. Each script is stand-alone and reads its bearer token from CRYPTOHOPPER_TOKEN. Includes a sub-package.json pinning @cryptohopper/sdk + tsx, a strict tsconfig (typechecked clean against the SDK source), and a short examples/README.md explaining how to run them. Main README now points at the folder from the Quickstart section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The original example used apiKey: '' on the assumption that public market-data endpoints accept anonymous calls. Two issues: 1. The SDK throws TypeError on empty apiKey at construction. 2. Even with any token, the API gateway requires a real OAuth bearer on every call — there are no anonymous routes. So the example crashed at line 1 (SDK validation) before ever hitting the wire. Renames the file to drop the 'public-' prefix that no longer makes sense, and updates the example to read CRYPTOHOPPER_TOKEN like every other example in this folder. Same auth-claim cleanup that landed across SDK READMEs and wikis from cryptohopper-resources#9.
Contributor
Author
|
Pushed a follow-up commit renaming |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds five self-contained TypeScript examples for the most common usage patterns. Each script is one file, reads its bearer token from
CRYPTOHOPPER_TOKEN, and runs withnpx tsx <file>.ts.public-ticker.tswhoami.tslist-hoppers.tserror-handling.tsCryptohopperErrorcodes / status /retryAfterMs/ serverCodestart-backtest.tsWhy
Currently a new user lands on the README, gets a Quickstart snippet, and has no working file they can
git clone && cd && npx tsxinto. Every adjacent SDK ecosystem (Stripe, Twilio, Supabase) ships anexamples/folder for exactly this reason. This is the missing on-ramp.Layout
examples/package.jsonis a separate workspace pinning@cryptohopper/sdk+tsx+typescript@6+@types/node@25. It does not affect the SDK's published surface.examples/tsconfig.jsontypechecks the scripts in strict mode against the builtdist/typings. Verified clean (tsc --noEmitexit 0).examples/.gitignorekeepsnode_modules/and a per-folderpackage-lock.jsonout of git.Test plan
tsc --noEmitexits 0 for every examplenode --experimental-strip-types --checkpasses on every exampleCRYPTOHOPPER_TOKEN=… npx tsx whoami.tsruns end-to-end against prodnpx tsx public-ticker.tsworks without any token