An API server for core data on places of the world.
http://cosmopolitan.openspending.org/
This API provides information about countries, cities and currencies all over the world and can be used as a cataloged data for various reasons.
Just a brief summary:
Based on https://github.com/coderholic/django-cities
Add param format=json in every request you want to perform to get JSON responses.
For example: GET /v1/?format=json.
API has self-documented format, so when you request to / (root of the API without any params) you'll get descriptions of all endpoints and can follow them for more descriptions.
You could also use filters when using this API:
/v1/countries/?continents={id} - get countries of the particular continent;/v1/countries/?continents={id},{id},{id} - get countries belongs to several continents.Example: GET /v1/countries/?continents=an, GET /v1/countries/?continents=an,af
/v1/currencies/?countries={id} - get currencies of the particular country;/v1/currencies/?countries={id},{id},{id} - get currencies belongs to several countries.Example: GET /v1/currencies/?countries=aq, GET /v1/currencies/?countries=aq,af
/v1/cities/?countries={id} - get cities of the particular country;/v1/cities/?countries={id},{id},{id} - get cities belong to several countries.Example: GET /v1/cities/?countries=gr, GET /v1/cities/?countries=gr,us
/v1/cities/?regions={id} - get cities of the particular region;/v1/cities/?regions={id},{id},{id} - get cities belong to several regions.Example: GET /v1/cities/?regions=tx, GET /v1/cities/?countries=tx,il
/v1/cities/?continents={id} - get cities of the particular continent;/v1/cities/?continents={id},{id},{id} - get cities belong to several continents.Example: GET /v1/cities/?continents=eu, GET /v1/cities/?continents=eu,af
/v1/cities/?slugs={slug} - get cities matching the particular slug, ;/v1/cities/?slugs={slug},{slug},{slug} - get cities matching to several slugs.Example: GET /v1/cities/?slugs=athens, GET /v1/cities/?slugs=athens,paris
** where slug means the name of the city in lowercase with no accents and instead of spaces, hyphens "-"
You can also define multiple filters on the city endpoint.
Example: GET /v1/cities/?slugs=athens,paris&countries=us®ions=tx
/v1/countrypolygons/?countries={id},{id},{id}/v1/countrypolygons/?regions={id},{id},{id}/v1/polygons/?countries={id},{id},{id}/v1/polygons/?regions={id},{id},{id}Under virtual env (to create virtualenv, run python3 -m venv env):
source env/bin/activate
export LOCAL_DEV=1
export DEBUG=1
Postgres + PostGIS setup (OS X):
brew install postgis
createuser cosmopolitan
createdb cosmopolitan
psql cosmopolitan
alter user "cosmopolitan" with password '123456';
grant all privileges on database cosmopolitan to cosmopolitan;
CREATE EXTENSION postgis;
If you want your user to have super privileges:
ALTER USER cosmopolitan WITH SUPERUSER;
If you just pulled this repo, you need to:
./manage.py migrate./manage.py cities --import=all;./manage.py importCosmopolitan is opensource, licensed under a standard MIT license (included in this repository as LICENSE).
Data sources licensies:
Content type
Image
Digest
Size
35.8 MB
Last updated
over 9 years ago
docker pull openspending/cosmopolitan