GithubHelp home page GithubHelp logo

sparkfabrik / nominatim-openapi Goto Github PK

View Code? Open in Web Editor NEW
3.0 6.0 1.0 5.83 MB

OpenAPI specification for OpenStreetMap Nominatim API (unofficial).

Home Page: https://sparkfabrik.github.io/nominatim-openapi/

License: MIT License

Makefile 37.20% Shell 62.80%
nominatim openapi openstreetmap swagger json-schema

nominatim-openapi's Introduction

Nominatim OpenAPI Specification

Unofficial OpenAPI Specification (OAS) for Nominatim API provided by OpenStreetMap project (OSM).

Getting started

Open sparkfabrik.github.io/nominatim-openapi in a browser. Choose the endpoint you are interested in and click on "Try it out". Fill all needed options and click on "Execute", you can see query and results under the "Responses" section.

You can download the formal API specification from here: sparkfabrik.github.io/nominatim-openapi/nominatim.openapi.json.

Context and motivations

Nominatim by OpenStreetMap is one of the best FOSS alternative for geolocation tasks, both as a service and self-hosted.

Exposed API is well documented by the official documentation, but it lacks a formal specification such as the well-known OpenAPI (a de-facto standard for REST API).

Some drawbacks of actual API implementation (waiting for version 2, see the planning board) can not be represented by OpenAPI and JSON Schema specifications, but we think that also a partial description can be very useful for end-users and developers (think about code generators for client and server).

This project aims to fill the hole and offer to community a robust, modern, and machine-readable description of the Nominatim API.

How to use

Playground

Getting started section shows how to use the official interactive playground hosted by Github Pages. If you want to locally run your own playground, you must download this repository (via zip download or git clone).

Source of OAS is in src/ folder, all final files (bundled and minified) are in docs/ folder.

You can't simply open the docs/index.html file in your browser, because of default Cross-Origin Policy. So you need to serve docs/ folder using a web server running locally.

In a javascript-ready environment (ie. with node and npm installed), you can run make serve in a terminal from the project folder and point your browser to http://localhost:8080.

In a Docker-ready environment, you can run make ui to have the playground exposed on http://localhost:8091.

Security

You can verify the integrity of deployed spec using the sha512 checksum provided.

You can run make checksum and make verify to compute and verify the checksum.

Refs: #6.

Versioning

This spec follows the Nominatim API versioning, so it use the same tags of the original project.

Roadmap

A this early stage, we are discussing the roadmap in a dedicated issue. When ready, the following table will be updated.

Milestone Task TBD To do Doing Done Refs
OpenAPI Spec /search endpoint #2
/lookup endpoint #4
/reverse endpoint #3
/status endpoint #5
/details endpoint #13
/deletable endpoint #13
/polygons endpoint #13
Test suite
Node CLI

Contributing

Any contribution is welcome!

Please read and accept our Code of Conduct, then refer to Contributing Guidelines before opening issues or pull requests.

Contributions to OpenAPI Specification

First of all, search for issues or open one to share your thoughts, needs or intents with the maintainers and the community. Then fork and clone this repo, make your changes, commit and push them on a new branch, finally open a PR against main branch of this repo.

Pre-requisites: git, make, shasum, npx (node and npm), docker.

Editable source of OAS is in src/ folder. You can validate it running make validate. You can bundle it running make build.

Please activate the Git Hooks provided in .githooks/ folder before the first change (hooks are bash scripts). You can simply run make hooks to activate them.

  • pre-commit - validate and bundle OAS spec, compute sha512 checksums.
  • pre-push - verify the checksums.

In a Docker-ready environment, you can run make editor to have the new Swagger Editor up and running on http://localhost:8092. Automatic file loading and saving is not available, so you must copy/paste the content of src/nominatim.openapi.json in the editor and then copy/paste it back to save the changes.

FAQ

What is OpenAPI?

Website: https://www.openapis.org

Repository: https://github.com/oai

Also known as: Swagger (see history)

Latest version: v3.1.0

The OpenAPI Specification (OAS) is a specification language for HTTP APIs that provides a standardized means to define your API to others. You can quickly discover how an API works, configure infrastructure, generate client code, and create test cases for your APIs. Read more about how you can get control of your APIs now, understand the full API lifecycle and communicate with developer communities inside and outside your organization.

What is JSON Schema?

Website: https://json-schema.org

Repository: https://github.com/json-schema-org

Latest version: v2020-12

JSON Schema enables the confident and reliable use of the JSON data format.

What is Swagger UI?

Website: https://swagger.io/tools/swagger-ui/

Repository: https://github.com/swagger-api/swagger-ui

Latest version: v5.1.0

Swagger UI allows anyone - be it your development team or your end consumers - to visualize and interact with the API's resources without having any of the implementation logic in place. It's automatically generated from your OpenAPI (formerly known as Swagger) Specification, with the visual documentation making it easy for back end implementation and client side consumption.

What is OpenStreetMap?

Website: https://www.openstreetmap.org

Repository: https://github.com/openstreetmap

OpenStreetMap is a map of the world, created by people like you and free to use under an open license. It is built by a community of mappers that contribute and maintain data about roads, trails, cafés, railway stations, and much more, all over the world.

What is Nominatim?

Website: https://nominatim.org

Repository: https://github.com/osm-search

Nominatim uses OpenStreetMap data to find locations on Earth by name and address (geocoding). It can also do the reverse, find an address for any location on the planet.

What is GeoJSON?

Website: https://geojson.org

Repository: https://github.com/geojson

GeoJSON is a format for encoding a variety of geographic data structures.

What is GeocodeJSON?

Website: https://github.com/geocoders/geocodejson-spec/tree/master/draft

Repository: https://github.com/geocoders/geocodejson-spec

This specification attempts to create a standard for handling geocoding results.

What is Subresource Integrity (SRI)

Website: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity

Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch e delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.

What are Secure Hash Algorithms (SHA)

Website: https://en.wikipedia.org/wiki/SHA-2

The Secure Hash Algorithms are a family of cryptographic hash functions published by the National Institute of Standards and Technology (NIST).

Drawbacks

Nominatim (and OpenStreetMap) project have a long story and a non trivial development path, so this OpenAPI specification reflects some features of actual software and official documentation.

Open Source Software

This project would not exist without open source, it is open source, and the community behind it contributes to open source.

Here is a list of external contributions (code and discussions) starting from work for this project:

License

MIT license on OpenAPI Specification. Geolocated data from OSM are provided under the ODbL license. Please read and accept the Nominatim Usage Policy before any use.

Acknowledgements

Many thanks to all OpenStreetMap contributors.

Pictures for this project are generated using Midjourney.

nominatim-openapi's People

Contributors

edodusi avatar jenkin avatar tegola avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tegola

nominatim-openapi's Issues

[Feature]: Add debug endpoints

Describe the solution you'd like

The official documentation describes also the /details, /deletable, and /polygons endpoints. We should add it to paths section and describe all accepted parameters.

Describe alternatives you've considered

These endpoints are for debug or maintenance purposes and we can ignore them.

Additional context

Some useful resources:

Code of Conduct

  • I agree to follow this project's Code of Conduct

Add an automatic tests suite

Describe the solution you'd like

Swagger Editor can check the specs for syntax issues or invalid openapi yaml, but we need to test also endpoints and json schemas.

Is your feature request related to a problem?

Yes, at this moment we can't test errors in endpoints or json schemas and this should be mandatory for the first stable release.

Describe alternatives you've considered

Handmade checks using the playground.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Roadmap

Here I'm proposing final goals and a development roadmap for this project, discussion is open!

Change default format from `jsonv2` to `geocodejson` for `/search` endpoint

Is your feature request related to a problem? Please describe.
Right now the official default format value for the /search endpoint is jsonv2 (see documentation) and the spec describes this response. But this discussion suggests that the best output format is geocodejson described by this spec.

Describe the solution you'd like
Change default format value of the OpenAPI spec to geocodejson and describe only this output in json schema. We should find or write the json schema for the geocodejson spec, but it is an extension of GeoJSON that already has an official json schema.

Describe alternatives you've considered
We can strictly follow the Nominatim documentation, but jsonv2 format has several well-known drawbacks and probably the next v2 of the api will drop it.

Additional context
Some useful resources:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.