Is there a simple free REST API where I can send the name or code of a country and get in return geojson data which highlights it's borders ?

I'm writing an application where I will have a changing list of countries and I have to outline their surface/borders on a openlayers map.

I've perfected/learned how to do it using sample geojson from this github but I haven't been able to find a RESTful api which serves me similar data?

Does anyone know of such a service, bonus points if I can send multiple country names at once so I don't need to make a lot of calls.

up vote 4 down vote accepted

ThePlacename.com has an api that returns place borders in GeoJSON format: http://theplacename.com/restapi

If you do not find any it is not difficult to set up your own. Install Geoserver and you can get geojson out from WFS with requests like

http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.0.0&request=getfeature&typename=topp:states&outputformat=application/json&propertyname=STATE_NAME,the_geom&CQL_FILTER=STATE_NAME=%27Illinois%27

You just need to install world_boundaries shapefile into your server or save it into PostGIS database and you have a pretty rest-alike service for country borders.

I've perfected/learned how to do it using sample geojson from this github but I haven't been able to find a RESTful api which serves me similar data?

Why would you want this as a REST interface? A pinch of JavaScript would filter that GeoJSON file down to specific countries. Remember, GeoJSON is JSON is JavaScript, and FeatureCollections are just arrays. They are malleable.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.