feat: add usage and web2app resources (#parity)#5
Merged
Conversation
Add two new resources to reach parity with the MCP server, both sync and
async:
- usage.get() -> GET /api/user/stats -> UsageStats (live consumption +
tier limits + overage; distinct from me.get() static profile)
- web2app.consume_session(token) -> GET /api/v1/web2app/{token} ->
Web2AppSession (single-use, 24h TTL)
New Pydantic v2 models (camelCase aliases): UsageStats, UsageLimits,
UsageOverage, Web2AppSession. Limit fields that the API returns as either
an int cap or the literal "unlimited" are typed Optional[Union[int, str]].
Wired into Client and AsyncClient, exported from package surface. Tests
cover sync + async for both resources, including an "unlimited" limit
value and endpoint-path assertions. Version bumped 1.1.0 -> 1.2.0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 two new resources to the Python SDK to reach parity with the AWSYS.CO MCP server. Both backend endpoints are API-key reachable, and both are implemented in the SDK's dual sync + async structure.
usage—client.usage.get()→GET /api/user/stats→UsageStats. Live account consumption (links, clicks, QR codes, API calls, tracked clicks) plus current tier limits and active overage state. Distinct fromme.get(), which returns the static profile.web2app—client.web2app.consume_session(token)→GET /api/v1/web2app/{token}→Web2AppSession. Single-use deep-link sessions with a 24h TTL; 400/404 are handled by the existing transport error mapping.New models (Pydantic v2, camelCase aliases)
UsageStats,UsageLimits,UsageOverage,Web2AppSession— all exported from the package surface.Flexible limit fields: The
/api/user/statshandler serializes unlimited caps (-1) as the literal string"unlimited"while finite caps stay integers. Verified against the live backend handler (functions/app/routes/user.js). Those fields (links_per_month,monthly_links,daily_links,monthly_tracked_clicks,qr_codes,folders) are typedOptional[Union[int, str]]to match the actual contract;api_calls_per_monthandcustom_slugsare always integers.Other
ClientandAsyncClient, mirroring existing resource attachment.__version__, which was stale at1.0.0).Test plan
pip install -e ".[dev]"thenpytest— 153 passed, 26 skipped (skips are credential-gated integration tests, unchanged).test_trust_score.py): assert endpoint path, parsed model fields, and an"unlimited"limit value.AsyncClientwiring tests extended forusage+web2app.🤖 Generated with Claude Code