/locations-API

Live Tanzania 🇹🇿 locations API 🔥

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

Description

Locations API from Tanzania locations repository.

Inspired by Mtaa API which was built using python & locations from a JSON file.

This is built using Prisma, NestJs & Postgresql database.

Setup

Create file .env then copy variables in sample.env

You need to provide Postgresql environment in enviroment file .env

Running the app

# install dependencies
$ npm install

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Access API

You can access this API using any Http Request tool (ie. Postman, Httpie, curl etc)

Available locations

  1. Countries
  1. Regions
  1. The same applies to Districts, Wards & Places

  2. Search (POST request)

    https://locations.webongo.services/search searchText=n

    (n.length >= 3)

  3. Whatever you query by id (Regions, Districts, Wards, Places)

you get it's discending location roots using Prisma relations.

The syntax is the same for other objects

Replace regions with districts, wards & places to get the specific location you want.

Live Examples

Get all regions

curl https://locations.webongo.services/regions

Get all districts

curl https://locations.webongo.services/districts

Get all wards

curl https://locations.webongo.services/wards

Get all places -> May be a bit slow & big bodied ;-)

curl https://locations.webongo.services/places

Search a Location

curl -X POST -d 'searchText=mtakuja'
https://locations.webongo.services/search

Credits