Skip to content

Expose a public read-only places API #123

Description

@AnayDhawan

Problem

The dataset is the most useful thing this project has, and the only way to consume it programmatically is to clone the repo and parse the JSON files yourself. There is no way to build anything on top of it.

Where to start

  • data/places/*.json - the source files, one per category
  • data/places.schema.json - the existing contract, document this rather than inventing a second one
  • Add the route under src/app/api/places/

What to build

GET /api/places returning the merged dataset, with optional city, category and country filters.

Bound the response. Returning every record unpaginated will not age well as the dataset grows, so add limit and offset with a sane default and a hard maximum.

Set cache headers that reflect reality: the data changes a few times a week at most.

Enable permissive CORS, since the entire point is other people's browsers.

Add a short docs page describing the response shape and linking the schema.

Acceptance criteria

  • /api/places returns the dataset with working city, category and country filters
  • limit and offset work, with a documented default and maximum
  • Invalid filter values return 400 rather than being silently ignored
  • Response includes cache headers and permissive CORS
  • A docs page describes the shape and links to data/places.schema.json

Verifying

npm install
npm run dev
curl "http://localhost:3000/api/places?city=Mumbai&limit=5"
curl "http://localhost:3000/api/places?limit=999999"   # should clamp, not dump everything

Scope: medium, roughly 2 hours.

New to the repo? Start with CONTRIBUTING.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgrowthDistribution and tractionhelp wantedExtra attention is welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions