Skip to navigation

Introduction

View as Markdown

Public, unauthenticated API that the Marqii embeddable widget (packages/widget) calls to load a published widget’s data and config.

Served by packages/express-api (ECS) behind CloudFront at https://embed.marqii.com.

Endpoint

GET /api/v2/public/widget/{widgetId}?widgetType={widgetType}

ParamInRequiredNotes
widgetIdpathyesUUID of the published widget
widgetTypequeryyesOne of menus, hours, reviewForms, faq, reviews. Must match the type the widget was published as
If-None-MatchheadernoETag from a previous response. Returns 304 when unchanged

The widget is read from DynamoDB (pk id, sk type). Large menus widgets are stored as gzipped partitions (menus#<menuId>); the API merges and decompresses them, sorts by position, and returns the same shape as an uncompressed widget.

Every 200 response also includes a geo object built from CloudFront viewer headers (latitude, longitude, ip, country, city). All of its fields are null when the headers are missing (for example, when the API is called directly instead of through CloudFront).

Caching

  • ETag is a strong ETag. Access-Control-Expose-Headers: etag lets the browser read it.
  • Cache-Control: s-maxage=3600, stale-while-revalidate=604800, stale-if-error=604800 means CloudFront caches for 1 hour and serves stale content for up to 7 days.
  • The widget stores the ETag and body in localStorage (marqii::widget::eTag-<id> / marqii::widget::data-<id>) and sends If-None-Match on the next load.

Errors

StatusBodyWhen
400{"message":"error missing query"}widgetType missing
400{"message":"Invalid widget id","errors":[...]}widgetId is not a UUID
400{"message":"Invalid widget type","errors":[...]}widgetType is not a known type
400{"message":"validation error","errors":[...]}Stored widget fails schema validation
404{"message":"not found"}No widget with this id + type
404{"status":404,"message":"Not Found"}Unknown route
500{"message":"..."}Unexpected error