Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GET endpoints to load municipality data via the API #557

Closed
2 tasks done
Greenheart opened this issue Jan 16, 2025 · 0 comments · Fixed by #572
Closed
2 tasks done

Add GET endpoints to load municipality data via the API #557

Greenheart opened this issue Jan 16, 2025 · 0 comments · Fixed by #572
Assignees

Comments

@Greenheart
Copy link
Collaborator

Greenheart commented Jan 16, 2025

This allows us to load all data from the same place.

If we add the municipality data to the API, we could get better OpenAPI docs which would make it easier to get AI:s to generate frontend code using the expected data.

This would also make it easier for others outside of Klimatkollen to use the open datasets that we've compiled and processed.

Initial tasks

  • GET /municipalities - list all climate-data.json
  • GET /municipalities/:municipalitySlug (or ID) - details for specific municipality

Implementation ideas

  • Add https://github.com/Klimatbyran/klimatkollen/blob/staging/data/output/climate-data.json to garbo
  • Create a municipalityService which supports getMunicipalities() and getMunicipality(name: string)
  • In the municipalityService, load climate-data.json and keep a Map in memory to allow returning company data quickly.
  • Implement the cache() plugin to make the client save responses.
  • Generate zod schemas based on the JSON data, for example with https://app.quicktype.io/. Use these both to parse the incoming data from the Python data pipeline when garbo starts, to ensure we get the expected data format. Also define the same schemas for the API endpoints response schemas. This will also add this to the API documentation.
@Greenheart Greenheart changed the title Consider adding municipality data to the API to publish all data in the same place Add GET endpoints to load municipality data via the API Jan 22, 2025
@Greenheart Greenheart self-assigned this Jan 23, 2025
@Greenheart Greenheart added this to Garbo Jan 23, 2025
@Greenheart Greenheart moved this to In Progress in Garbo Jan 23, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Garbo Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant