Activities
Activities are the bookable products. They moved from a flat city/region/tripCategory/tripType model to a normalised catalog: Location (tree with locationAncestors), Category, Keyword, and join models for food, transport, restrictions and mandatory items.
Endpoints
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| GET | /activity | Public | List published activities |
| GET | /activity/by-path?path=... | Public | Resolve an activity by its canonicalPath |
| GET | /activity/popular | Public | Top activities by popularityScore |
| GET | /activity/:id | Public (with owner/admin exception) | Activity detail |
| GET | /activity/supplier/:supplierId | Supplier | Activities for a supplier |
| GET | /activity/a/ | Admin | All activities (including unpublished) |
| POST | /activity | Auth (supplier/admin flow) | Create activity |
| PATCH | /activity/:id | Auth | Update activity |
| PATCH | /activity/:id/feature | Admin | Toggle featured |
| PATCH | /activity/:id/promotion | Admin | Set promotion expiry |
| DELETE | /activity/:id | Auth | Delete activity |
Listing
GET /api/v1/activity?location=pokhara&category=trekking&search=everest&minPrice=500&maxPrice=2000&page=1&limit=20Filters:
| Param | Behaviour |
|---|---|
location or city | Finds the Location by slug, then matches activities where locationAncestors contains it. Unknown slugs return no results. |
category | Matches category.slug or numeric categoryId. |
search | Case-insensitive contains on title. |
minPrice / maxPrice | Numeric range on price. |
page / limit | Pagination via getPaginationParams. |
The public list is ordered by popularityScore desc, then id asc. Detail-heavy columns (fullDescription, itinerary, meta, highlights, inclusions, exclusions, whatToBring, urlHistory) are omitted from list responses.
Detail
GET /activity/:id requires published = true and status = APPROVED unless the caller is the owner (supplier cookie) or an admin (admin cookie). When public, the endpoint increments views fire-and-forget and calls Recombee to attach similar activities. Similar activities are filtered back to published + approved before being returned.
GET /activity/by-path is used by the frontend's catch-all route to resolve SEO-friendly paths from canonicalPath.
Status lifecycle
DRAFT → PENDING_APPROVAL → APPROVED (published=true)
→ REJECTED (published=false)Enum values: PENDING_APPROVAL, APPROVED, REJECTED, SUSPENDED. isFeatured and promotedUntil control homepage placement.
Popularity
GET /activity/popular filters published = true and status = APPROVED with popularityScore > 1, ordered by score desc. The score is recalculated hourly by the API cron (0 * * * *) using a single SQL update that only touches rows whose score changed:
score = views*1 + bookingsCount*10 + averageRating*20 + (isFeatured?100:0) - (daysSinceCreation*0.5)Supplier management
Suppliers can create and update their own activities via POST /activity and PATCH /activity/:id. The API resolves the supplier from the auth token and enforces ownership. Activities created by suppliers typically start in PENDING_APPROVAL.