Giter Site home page Giter Site logo

ncdanhvn / vn-provinces-api Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 172 KB

Public API for getting Vietnam geographical data likes regions, provinces, districts, wards and some related administration information

Home Page: https://vnprovinces.pythonanywhere.com

Python 33.64% HTML 52.62% CSS 5.28% JavaScript 8.46%
api districts django provinces regions restful vietnam wards

vn-provinces-api's Introduction

alternative text Vietnam Provinces API

PythonDjangoMySQLHtmlCSSVueJS

VN Provinces API is an open API that provides information about administrative units in Vietnam across four levels:

  • Region
  • Province
  • District
  • Ward

For more information about API usecases, documentation, please visit links below:

Tech Stack

Server: Django, Rest Framework

Databases: MySQL

Client: Html, Vanilla CSS, VueJS, Vuetify

Documentation: OpenAPI, drf-spectacular

Contributing

Contributions are always welcome!

Please fork the repo then start pull requests.

Installation

  • Firstly clone this repository
  git clone https://github.com/ncdanhvn/vn-provinces-api.git
  cd vn-provinces-api
  • This project uses pipenv to manage virtual environment. Let's install pipenv first, then install project dependencies.
  pip install pipenv 
  pipenv install
  • To run API local on your machine, you need a SQL server. Download and install MySQL here

  • After installing MySQL server, you will have a root user with password. Let's enter these information in development settings file at this address: province > settings > dev.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'province',
        'HOST': 'localhost',
        'USER': 'YOUR_USERNAME',
        'PASSWORD': 'YOUR_PASSWORD'
    }
}
  • The last step to setup our database is to create province database on the server which we've just installed. Open mysql shell and run create database command.
  CREATE DATABASE province;
  • Congratulation now everything set and we are ready to run API on our machine
  pipenv shell
  python manage.py migrate
  python manage.py runserver
  • Checkout the homepage of API at default url: http://127.0.0.1:8000/

  • At this point, everything should work, but if you visit the api endpoint like http://127.0.0.1:8000/api/provinces, the response results would be empty, since there is nothing on our database. So let's populate database with some demo data.

  python manage.py seed_test_db

Running Tests

Repository already has all tests to test endpoint behaviours, there are total 9 tests for 9 endpoints. To run tests, please do following steps:

First install necessary development packages:

  pipenv install --dev

Then run tests:

  pytest

License

MIT

vn-provinces-api's People

Contributors

ncdanhvn avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.