Skip to content

feature(Preview): Add --preview flag for free preview dataset access#16

Merged
szemyd merged 1 commit into
mainfrom
claude/preview-demo-key-default-x01hgv
Jul 2, 2026
Merged

feature(Preview): Add --preview flag for free preview dataset access#16
szemyd merged 1 commit into
mainfrom
claude/preview-demo-key-default-x01hgv

Conversation

@szemyd

@szemyd szemyd commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for querying the free preview dataset via a new --preview flag, 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

  • New --preview flag: Allows users to query the free preview dataset without a subscription or API key
  • Demo API key: Introduced DemoAPIKey constant that is automatically used when --preview is specified and no API key is set
  • API endpoint routing: Modified FetchPresignedUrls() to route preview requests to /data/preview/{metric} instead of /data/{metric}
  • Relaxed API key requirement: The APERIODIC_API_KEY environment variable is now optional when using --preview
  • Updated documentation: Added usage examples and clarification in README about preview data requirements
  • Comprehensive test coverage: Added three new tests (TestCLI_Preview_NoAPIKeyUsesDemoKey, TestCLI_Preview_KeepsProvidedAPIKey, TestCLI_NoPreviewUsesDataPath) with a helper function captureCLIRequest() that uses httptest to verify correct API key and endpoint routing

Implementation Details

  • The API key validation logic was moved after flag parsing to allow checking the --preview flag before requiring an API key
  • When preview mode is enabled and no API key is provided, the shared demo key is used automatically
  • If a user provides their own API key, it is respected even in preview mode
  • The preview endpoint path is constructed conditionally based on the preview parameter passed through the call chain
  • Help text and error messages were updated to reflect that API keys are optional with --preview

https://claude.ai/code/session_011xobeF2kf8fwoygJfjRY3o

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
@szemyd szemyd changed the title Add --preview flag for free preview dataset access feature(Preview): Add --preview flag for free preview dataset access Jul 2, 2026

@almostintuitive almostintuitive 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.

👍

@szemyd
szemyd merged commit 7f83bbc into main Jul 2, 2026
10 checks passed
@szemyd
szemyd deleted the claude/preview-demo-key-default-x01hgv branch July 2, 2026 15:02
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.

3 participants