Skip to content

Migrate to Krónan Public API#3

Merged
arnif merged 1 commit into
mainfrom
migrate-to-public-api
Apr 9, 2026
Merged

Migrate to Krónan Public API#3
arnif merged 1 commit into
mainfrom
migrate-to-public-api

Conversation

@arnif

@arnif arnif commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Summary

This PR migrates the CLI from the legacy backend API to the new official Krónan Public API (https://api.kronan.is/api/v1/).

The Krónan Public API was recently announced as a beta release, providing a cleaner, more stable interface for interacting with Krónan's e-commerce platform.

Key Changes

🔐 Authentication

  • Replaced Cognito JWT auth flow with AccessToken authentication
  • New command: kronan token <access-token> (replaces kronan login <phone>)
  • Tokens created at https://kronan.is/adgangur/adgangslyklar
  • Tokens stored in ~/.kronan/token (simplified from JSON format)

🌐 API Updates

  • New base URL: https://api.kronan.is/api/v1 (was https://backend.kronan.is/api)
  • New auth header: Authorization: AccessToken <token> (was CognitoJWT)
  • Updated endpoints for all operations (search, orders, checkout, etc.)
  • Added support for all new features:
    • Categories: Browse products by category hierarchy
    • Order Modifications: Delete lines, lower quantity, toggle substitution
    • Product Lists: Full CRUD (create, read, update, delete, add/remove items)
    • Shopping Notes: Full management (Skundalisti/Scan and Go)
    • Purchase Statistics: View purchase history and frequency data

🛠️ CLI Commands (Comprehensive)

Authentication:

  • kronan token <token> - Save access token
  • kronan logout - Clear stored token
  • kronan status - Check authentication status

Products:

  • kronan search <query> - Search for products
  • kronan product <sku> - Get product details
  • kronan categories - List all categories
  • kronan category <slug> - Browse products by category

Orders:

  • kronan orders - View order history
  • kronan order <token> - View specific order details
  • kronan order delete-lines <token> <lineIds...> - Delete order lines
  • kronan order lower-quantity <token> <lineIds...> --quantity N - Lower quantity
  • kronan order toggle-substitution <token> <lineIds...> - Toggle substitution

Cart:

  • kronan cart - View cart contents
  • kronan cart add <sku> [qty] - Add item to cart
  • kronan cart clear - Clear cart

Product Lists:

  • kronan lists - List all product lists
  • kronan lists create <name> [--description "..."] - Create new list
  • kronan lists view <token> - View list details
  • kronan lists delete <token> [--force] - Delete a list
  • kronan lists add <list-token> <sku> [qty] - Add item to list
  • kronan lists remove <list-token> <sku> - Remove item from list
  • kronan lists clear <token> [--force] - Clear all items from list

Shopping Notes (Skundalisti):

  • kronan notes - View shopping note
  • kronan notes add [--text "..."] [--sku SKU] [--quantity N] - Add item
  • kronan notes update <line-token> [--text "..."] [--quantity N] - Update item
  • kronan notes remove <line-token> - Remove item from note
  • kronan notes toggle <line-token> - Toggle item completion
  • kronan notes clear [--force] - Clear all items from note
  • kronan notes archived - View completed items

Purchase Statistics:

  • kronan stats [--limit N] [--offset N] [--include-ignored] - View purchase history
  • kronan stats ignore <id> - Hide product from stats
  • kronan stats unignore <id> - Unhide product from stats

Identity:

  • kronan me - Show current identity

🧪 Testing

  • Updated all tests for new API structure
  • Added tests for new response format handling
  • All 13 tests passing
  • Lint and typecheck passing

📚 Documentation

  • Updated README.md with new auth flow and all commands
  • Updated CLAUDE.md with new API endpoints
  • Updated SKILL.md for AI agent usage

API Reference

Testing Done

✅ Token authentication works
✅ Product search (with pagination)
✅ Product details
✅ Categories and category browsing
✅ Order history and details
✅ Order modifications (delete lines, lower quantity, toggle substitution)
✅ Cart view, add, clear
✅ Product lists (full CRUD)
✅ Shopping notes (full management)
✅ Purchase statistics
✅ All tests passing

Breaking Changes

⚠️ Migration required for existing users:

  1. Create new access token at https://kronan.is/adgangur/adgangslyklar
  2. Run kronan token <your-new-token>
  3. Old ~/.kronan/tokens.json can be removed

Related

Krónan announcement: https://www.facebook.com/kronan/posts/...

This PR migrates the CLI from the legacy backend API to the new official
Krónan Public API (https://api.kronan.is/api/v1/).

Key changes:
- Replace Cognito JWT auth with AccessToken authentication
- Update all API endpoints to match Public API specification
- Add support for new features: product lists, shopping notes, purchase stats
- Update CLI commands: 'token' replaces 'login', improved cart handling
- Fix response format handling (some endpoints return objects vs arrays)
- Update all documentation (README, CLAUDE.md)
- Update and add tests for new API structure

Breaking changes:
- 'kronan login <phone>' removed - use 'kronan token <access-token>' instead
- Auth tokens stored in ~/.kronan/token instead of ~/.kronan/tokens.json
- Cart commands simplified (replace/update/remove -> add/clear)

See https://api.kronan.is/api/v1/schema/swagger-ui/ for API docs.
@arnif arnif force-pushed the migrate-to-public-api branch from f3d4f67 to 8c9d710 Compare April 9, 2026 16:51
@arnif arnif merged commit baf0c59 into main Apr 9, 2026
1 check passed
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.

1 participant