This is places REST API service like geoapify
or another similar geographic API with querying and finding places in radius.
- This API works with role-based auth, so if you want to create/update/delete places you must provide one of the master keys in
token
querystring
-
POST:/auth
- returns API token with expiration timeBody
{ "email": "mr_robot@ecorp.com" }
Response
{ "token": "<YOUR_TOKEN>", "expiresIn": "24h" }
-
POST:/places
(admin route) - creates place with provided fields and returns created place with generated_id
and timestampsBody
{ // required "category": "goverment", // required "subcategories": ["services", "police"], // required "datasources": ["OSM", "google maps"], "geo": { "coordinates": [34.312321, 62.12476456], // required "lat": 34.312321, //required "long": 62.12476456, // required "country": "Russia", "country_code": "RU", "city": "Moscow", "region": "Khimki", "state": "SZAO", "state_code": "sz", "suburb": "Leninski prospect", "street": "Pushkinskaya", // required "full_address": "Moscow, Khimki, Pushkina 12/23", "address_line1": "string", "address_line2": "string", "address_line3": "string", "postcode": 123457, "third_party": { "google_maps_link": "<GM link>", "osm": "<osm link>", "osm_id": "asdada1231231" } }, "place": { // required "name": "Police department of Khimki", "full_name": "GU MVD of Khimki, Moscow Oblast", "old_name": "Deputy of Khimki", "description": "Police department, located near west road", "is_heritage": false, "is_guarded": true, "authorized_personeel_only": true, "is_goverment_property": true, "founded_by": "Department of Justice of Moscow", "builded_at": "2024-08-11T15:48:00.852Z", "construction_started_at": "2024-08-11T15:48:00.852Z", "builded_by": "REDACTED", "open_hours": { "from": 0, "to": 24 }, "is_always_open": true, "age_from": 21, "facilities": ["parking"], "wikipedia": "<wiki link>", "images": "http://images.com/police-department/1" }, "contacts": { "website": "http://khpd.ru", "websites": ["http://khpd.ru"], "phone_number": "911", "phone_numbers": ["911"], "email": "khpd@p.ru", "emails": ["khpd@p.ru"], "links": ["http://khpd.ru"] }, "law": { "owner": "Department Of Justice", "owner_law_address": "ae12424", "owner_phisycal_address": "Kremlyn", "license": "gov12313", "corp": "S.T.A.R.S." } }
Response
{ "_id": "66b744dbde0cb7ff86d627ad", "category": ..., "subcategories": ..., "datasources": ..., "geo": { ... }, "place": { ... }, "contacts": { ... }, "law": { ... }, "createdAt": "2024-08-10T10:45:47.522Z", "updatedAt": "2024-08-10T10:45:47.522Z", "__v": 0 }
-
PATCH:/places
(admin route) - updates place with provided fields and returns updated placeBody
{ "law": { "owner": "Department Of Justice", "owner_law_address": "[REDACTED]", "owner_phisycal_address": "[REDACTED]", "license": "[REDACTED]", "corp": "S.T.A.R.S." } }
Response
{ "_id": "66b744dbde0cb7ff86d627ad", "category": ..., "subcategories": ..., "datasources": ..., "geo": { ... }, "place": { ... }, "contacts": { ... }, "law": { "owner": "Department Of Justice", "owner_law_address": "[REDACTED]", "owner_phisycal_address": "[REDACTED]", "license": "[REDACTED]", "corp": "S.T.A.R.S." }, "createdAt": "2024-08-10T10:45:47.522Z", "updatedAt": "2024-08-10T10:45:47.522Z", "__v": 0 }
-
DELETE:/places/:id
(admin route) - deletes place by_id
Response
{ "success": true }
GET:/places/:id
(user route) - returns found place by_id
-
Supports XML format, if you need given data to be in XML use
Content-Type
header withapplication/xml
Response
{ "_id": "66b744dbde0cb7ff86d627ad", "category": ..., "subcategories": ..., "datasources": ..., "geo": { ... }, "place": { ... }, "contacts": { ... }, "law": { ... }, "createdAt": "2024-08-10T10:45:47.522Z", "updatedAt": "2024-08-10T10:45:47.522Z", "__v": 0 }
GET:/places
(user route) - returns places by provided options
-
Supports XML format, if you need given data to be in XML use
Content-Type
header withapplication/xml
Options
Querystring Description Example value category Filters place by category shops
subcategories Adds additional categories, that can be divided by "." groceries.vegan
city Filters place by city (case is necessary) Moscow
country Filters place by country (case is necessary) Russia
state Filters place by state (case is necessary) Arizona
state_code Filters place by shortened state AZ
region Filters place by state region (case is necessary) Glendale
postcode Filters place by postcode (must be number) 123133
builded_by Filters place by creator/builder Stanford Professor
open_from Filters by place opening hours (24h format) 10
open_to Filters by place closing hours (24h format) 23
is_always_open Filters only always-open places (1 or 0) 1
age_from Filters by place minimal allowed age to enter (must be number) 18
facilities Filters by place facilities such as parking (string array) parking
disabled_support
owner Filters by place owner Donald Trump
license Filters by place license (or any law document) gambling_license
corp Filters place by owning corp Apple
sort Sorts places bu build date (1 or -1) -1
limit Pagination limit 1
offset Pagination offset 2
Response
[ { "_id": ..., "category": ..., "subcategories": ..., "datasources": ..., "geo": { ... }, "place": { ... }, "contacts": { ... }, "law": { ... }, "createdAt": ..., "updatedAt": ..., "__v": 0 }, { "_id": ..., "category": ..., "subcategories": ..., "datasources": ..., "geo": { ... }, "place": { ... }, "contacts": { ... }, "law": { ... }, "createdAt": ..., "updatedAt": ..., "__v": 0 } ]
- You can found schema at
/src/graphql/schemas/place.graphql
- To access Graphql use
/graphql
endpoint places
query supports all options that in http endpoint- To provide api token use
token
header, unlike queryparam in http endpoint
- Copy this repo
git clone https://github.com/LCcodder/places-api
- Install packages
npm i
- Configure environment variables in
.env
file - Make sure you running
Mongodb
- Run app
npm start