anylist_rs
A Rust crate for interacting with the grocery list management app AnyList's undocumented API.
use ;
async
Features
- Authentication: Bearer token authentication with automatic token refresh
- Lists: Create, read, update, and delete shopping lists
- Items: Full CRUD operations for list items including quantity, details, and categories
- Recipes: Create and manage recipes with ingredients and steps
- Categories, stores, and meal plans
- Token persistence: Save and restore authentication sessions
- Uses Protobuf-based AnyList API
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Examples
... or you can see my anylist_cli
Token Management
The client automatically manages authentication tokens and refreshes them on 401 errors. You can also save and restore sessions:
use ;
// Initial login
let client = login.await?;
// Export tokens for persistence (e.g., save to keychain/config)
let tokens: SavedTokens = client.export_tokens?;
// save_to_storage(&tokens)?;
// Later, restore from saved tokens
let tokens: SavedTokens = load_from_storage?;
let client = from_tokens?;
// Use the client - tokens automatically refresh on 401
let lists = client.get_lists.await?;
Monitoring Token Refresh
You can optionally track authentication events:
use ;
let client = login
.await?
.on_auth_event;
Disabling Auto-Refresh
If you want manual control over token refresh:
let client = login
.await?
.disable_auto_refresh;
// Now 401 errors will be returned instead of automatically refreshing
Possible future features
- Real-time sync via WebSockets
- Connect to WebSocket
wss://www.anylist.com/data/add-user-listener?access_token=<JWT> - Heartbeat protocol for connection health
- Handle "refresh-shopping-lists" messages for collaborative updates
- Connect to WebSocket
- Logical timestamps for conflict resolution
- Photo upload/download support (S3 presigned URLs)
- List folders and organization
- Recipe web import from URLs
- iCalendar feed export for meal planning
Disclaimer
I made this on my own, without help or knowledge from the AnyList folks. Please, don't use this for malice.