/cities-api

RESTful interface for fast accessing russian cities, districts and regions

Primary LanguageJavaScriptMIT LicenseMIT

Russian cities API


Public API

RESTful interface for fast accesing russian cities, districts and regions

https://cities-api.ml/cities


Documentation

Documentation is avaliable in Postman Documenter:

https://documenter.getpostman.com/view/5482678/SWLmWjBW?version=latest

If you can't access API through Postman, try to disable Self-signed SSL check in Settings -> SSL certificate verification


Example

Request:

curl --location --request GET 'https://cities-api.ml/cities?name=Новгород'

Response:

[
    {
        "name": "Нижний Новгород",
        "district_id": 7,
        "region_id": 38,
        "coordinates": "56.296504,43.936059",
        "id": 1337
    },
    {
        "name": "Великий Новгород",
        "district_id": 3,
        "region_id": 39,
        "coordinates": "58.525570,31.274193",
        "id": 1363
    }
]

Deploy your own service

  1. Install dependencies
yarn
  1. Build app
yarn build
  1. Run server
yarn start

SSL changes for production deployment

In app.js:

  1. Comment/delete lines below:
// import http from 'http';
// http.createServer(app).listen(serverPort, function() {
//   console.log(`Express server listening on port ${serverPort}`);
// });
  1. Uncomment following lines
import https from 'https';
https.createServer(options, app).listen(serverPort, function() {
  console.log(`Express server listening on port ${serverPort}`);
});
const options = {
  key: fs.readFileSync(path.join(__dirname, './path/to/private.key', 'private.key')),
  cert: fs.readFileSync(path.join(__dirname, './path/to/certificate.srt', 'certificate.srt')),
};
  1. Place your SSL certificates in ./path/to/private.key and ./path/to/certificate.srt