feature(Preview): Add --preview flag for free preview dataset access#16
Merged
Conversation
Add a --preview flag that routes data requests to /data/preview/{metric}.
When APERIODIC_API_KEY is unset and --preview is passed, the CLI falls
back to the shared public demo key (DEMO-KEY), so preview data can be
fetched without signing up. Without --preview a key is still required.
Flag parsing now runs before the key check so --preview can relax the
requirement. Adds stub-server tests covering preview routing, the demo-key
fallback, key precedence, and the default (non-preview) path, plus README
docs for the flag.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011xobeF2kf8fwoygJfjRY3o
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
This PR adds support for querying the free preview dataset via a new
--previewflag, eliminating the requirement for an API key when accessing whitelisted preview data. The CLI now automatically uses a shared public demo key when preview mode is enabled.Key Changes
--previewflag: Allows users to query the free preview dataset without a subscription or API keyDemoAPIKeyconstant that is automatically used when--previewis specified and no API key is setFetchPresignedUrls()to route preview requests to/data/preview/{metric}instead of/data/{metric}APERIODIC_API_KEYenvironment variable is now optional when using--previewTestCLI_Preview_NoAPIKeyUsesDemoKey,TestCLI_Preview_KeepsProvidedAPIKey,TestCLI_NoPreviewUsesDataPath) with a helper functioncaptureCLIRequest()that useshttptestto verify correct API key and endpoint routingImplementation Details
--previewflag before requiring an API keypreviewparameter passed through the call chain--previewhttps://claude.ai/code/session_011xobeF2kf8fwoygJfjRY3o