Skip to content

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 ​

MethodEndpointAuthPurpose
GET/activityPublicList published activities
GET/activity/by-path?path=...PublicResolve an activity by its canonicalPath
GET/activity/popularPublicTop activities by popularityScore
GET/activity/:idPublic (with owner/admin exception)Activity detail
GET/activity/supplier/:supplierIdSupplierActivities for a supplier
GET/activity/a/AdminAll activities (including unpublished)
POST/activityAuth (supplier/admin flow)Create activity
PATCH/activity/:idAuthUpdate activity
PATCH/activity/:id/featureAdminToggle featured
PATCH/activity/:id/promotionAdminSet promotion expiry
DELETE/activity/:idAuthDelete activity

Listing ​

http
GET /api/v1/activity?location=pokhara&category=trekking&search=everest&minPrice=500&maxPrice=2000&page=1&limit=20

Filters:

ParamBehaviour
location or cityFinds the Location by slug, then matches activities where locationAncestors contains it. Unknown slugs return no results.
categoryMatches category.slug or numeric categoryId.
searchCase-insensitive contains on title.
minPrice / maxPriceNumeric range on price.
page / limitPagination 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 ​

text
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:

sql
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.

Built with VitePress