This is nice if considered a programming exercise but it's actually pretty useless for real world use. This data is static, that is it very rarely changes. The whole dataset is also very tiny. It's just better to store this data in-house and don't provide unnecessary point of potential failure by using an external service. An idea on how to make it more useful is to provide downloadable data dump in several formats s…
Get information about any country via a RESTful API
11–20 of 27 posts
Re: Get information about any country via a RESTful API
#12Some of the data seems to be incorrect: http://restcountries.eu/rest/alpha2/za The South African currency is ZAR, not SOS. Cape Town is the legislative capital, but not _the_ capital. If you search by currency for ZAR: http://restcountries.eu/rest/currency/zar You get South Georgia. I assume that's meant to be South Africa.
Re: Get information about any country via a RESTful API
#13Re: Get information about any country via a RESTful API
#14Re: Get information about any country via a RESTful API
#15Obligatory warning: API is absolutely not restful.
Re: Get information about any country via a RESTful API
#16Obligatory warning: API is absolutely not restful.
GET:
http://restcountries.eu/rest/alpha/ee would be http://restcountries.eu/countries?alpha=ee
http://restcountries.eu/rest/name/norge would be http://restcountries.eu/countries?name=norge
That seems right, right?
Re: Get information about any country via a RESTful API
#17Obligatory warning: API is absolutely not restful.
After creating the representations of each of these resources, I would then create URI templates in my root response (I guess found at /rest) that allow for the searching aspect that this site is providing, which would be something like:
{
"_links": {
"search_by_name": {
"href": "/rest/name/{name}",
"templated": true
}
}
}
I may build on to this to provide other resources, like a collection of capitals, each with a link to "/rest/capital/{capital_city}", or a resource of currencies, linking to "/rest/currency/{currency}".The goal of all of this would be to tell the client how to find resources rather than having that hard-coded into the client. These are just some first steps toward being RESTful, and there are lots of different directions you could take this and still be RESTful.
edit: example was incomplete
Re: Get information about any country via a RESTful API
#18Obligatory warning: API is absolutely not restful.
Since the project seems to have an educational bent, what would the proper REST interface for it look like? GET: http://restcountries.eu/rest/alpha/ee would be http://restcountries.eu/countries?alpha=ee http://restcountries.eu/rest/name/norge would be http://restcountries.eu/countries?name=norge That seems right, right?
Re: Get information about any country via a RESTful API
#19Some of the data seems to be incorrect: http://restcountries.eu/rest/alpha2/za The South African currency is ZAR, not SOS. Cape Town is the legislative capital, but not _the_ capital. If you search by currency for ZAR: http://restcountries.eu/rest/currency/zar You get South Georgia. I assume that's meant to be South Africa.