API Integration
The mobile app uses a typed API layer in src/lib/api/* and a shared HTTP client in src/lib/api/client.ts.
Base Configuration
Source of truth: src/constants/api.ts
API_CONFIG.baseUrl- dev:
http://<DEV_API_HOST>:9000/api - prod:
https://api.thetrickbook.com/api
- dev:
API_CONFIG.socketUrl- dev:
http://<DEV_API_HOST>:9000 - prod:
https://api.thetrickbook.com
- dev:
HTTP Client Contract
Source of truth: src/lib/api/client.ts
- Automatically injects
x-auth-tokenfrom Expo Secure Store keyauth_token - Supports
skipAuthfor public endpoints - Uses request timeout + abort controller
- Normalizes network and API errors to a consistent shape
API Module Map
| Module | Primary endpoint group |
|---|---|
auth.ts | /auth, /users, /user |
trickbook.ts | /trickipedia, /listings, /listing, /categories |
spots.ts | /spots |
spotlists.ts | /spotlists |
spotReviews.ts | /spot-reviews |
homies.ts | /users/* |
messages.ts | /dm/* |
feed.ts | /feed/* |
couch.ts | /couch/* |
upload.ts | /upload/* |
user.ts | /user/* |
Authentication And Realtime
- REST auth header:
x-auth-token - Socket auth token: handshake
auth.token - Active socket namespaces from backend:
/feed/messages
Important Notes
- The repository still contains legacy code under
app/api/*; new feature work should usesrc/lib/api/*. - Endpoint constants in
src/constants/api.tsare the canonical mobile contract definitions. - If backend routes change, update both endpoint constants and any direct URL usage in the API modules.