Git Product home page Git Product logo

world-cities-api's Introduction

World Cities REST API

How to create a free city world api

When working with microservices, you will find yourself with various apps that need users to select a country or a city.

There are a lot of providers for such services out there, this however is an in-house solution that you can spin in a couple of seconds.

The dataset is based on Juanmah's work, but slightly striped.

How it works.

  • create an azure function app in Azure.
  • read the csv.
  • respond with the requested data.

Lets get started:

  1. clone repository.
  2. create a dotnet (3.1 we are still waiting for 6) Function App in azure.
  3. pulbish to function to the above function.
    1. When publishing make sure the option "run from a package" is false or 0. This makes wwwroot folder in Kudu readonly as the docs state.
    2. Create a folder, "Data" , using Kudu in the wwwwroot folder of the function.
    3. Upload your csv file to the Data folder in Kudu.
  4. test your function.

Expected output

  1. without parameter country you will get a list of all countries in the world. request without parameter
  2. with a paramter you will get a list of cities in that given country. request with parameter

Questions

  1. Is the data upto date? Yes, cities take time to form. If a city is missing please let me know so that I can update the dataset.
  2. Can the data be improved Yes, if the need arises we could add support for continent and other related data.
  3. How is the performance? It is just fine, check the response times in the pictures above.
  4. I want a faster response, can that be done? Yes, strip the file and remove fields that you don't need.
  5. Kudu cannot gives me a ERROR 409 Conflict ! Set WEBSITE_RUN_FROM_PACKAGE to 0 in your function app configuration in Azure. This app service feature makes the wwwroot folder readonly as referenced above.
  6. Well my local solution is not working ! Azure and a local development enviromrmnt have diffirent file structures, for debugging puposes change the root directory line to : var rootDirectory = Path.GetFullPath(Path.Combine(binDirectory, "..","..","..",".."));

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.