This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Poetry project. Essential commands:
poetry install- Install dependencies and set up development environmentmake clean- Remove generated code fromsrc/py_sp_api/generated/make generate- Update git submodule and regenerate API clients from Amazon's OpenAPI specsmake test- Run unit tests with pytestmake lint- Run flake8 linting checksmake fix- Auto-fix code formatting with black and autoflakemake lint-fix- Run fix then lint (recommended before commits)
This project generates Python API clients for Amazon's Selling Partner API using OpenAPI Generator. Key architectural components:
- Amazon's OpenAPI specs are maintained as a git submodule in
selling-partner-api-models/ scripts/generate_schemas.pyprocesses these specs and generates Python clients- Generated code is placed in
src/py_sp_api/generated/with separate modules for each API - Each generated module gets a copy of
base_client.pyfor SP-API authentication
SPAPIConfigclass handles both grantful (refresh_token) and grantless (client_credentials) authentication flowsSPAPIClientextends the generated OpenAPI client with Amazon LWA token management- Token caching is handled by
AccessTokenCacheto avoid redundant token requests - Custom AWS auth implementation in
src/py_sp_api/auth/(adapted from Amazon's reference implementation)
src/py_sp_api/auth/- Authentication components (LWA tokens, AWS signing)src/py_sp_api/generated/- Auto-generated API clients (do not manually edit)src/py_sp_api/base_client.py- Template that gets copied into each generated clientscripts/generate_schemas.py- Client generation script
- Black line length: 120 characters
- Generated code and git submodule are excluded from formatting
- Python 3.9+ required
- Uses pydantic v2 for data validation and requests for HTTP client
- Never manually edit files in
src/py_sp_api/generated/- they are overwritten during generation - Run
make generateafter updating theselling-partner-api-modelssubmodule - The project supports both marketplace-specific (grantful) and account-level (grantless) API operations
- Each API endpoint may have different authentication requirements - check Amazon's documentation