Countries List with images webservice
Is there a web service that you can call and get the list of countries and 开发者_运维知识库links to images of the flags to each nation.
http://www.geognos.com/geo/en/world-countries-API.html seems to be nice.
Been the author of the above API mentioned by Eric above- I am willing to help. If you need the flag of a particular country it is as simple as requesting it:http://www.geognos.com/api/en/countries/flag/GR.png
In order to get a json formatted output of all world countries you have to issue an HTTP GET request to http://www.geognos.com/api/en/countries/info/all.json You will receive a reply with information about all world countries. For each and every country there is a field called "SeqID". A png image of all flags arranged vertically is provided in:http://www.geognos.com/media/flags/world-countries-flags-80X40.png and:http://www.geognos.com/media/flags/world-countries-flags-32X16.png. These images can be used for serving individual flags as image sprites by offsetting vertical position using css sprites techniques. Offset values can be calculated by using the “IdSeq” field of the “info” request and image dimensions. This is the most efficient way for displaying lots of flags. For an example of using sprites you can look at the source code of the following page:http://www.geognos.com/api/en/countries/info/IT.html
You can contact me if U need any further help. Happy coding:-)
This service provides flags in SVG.
https://restcountries.eu/rest/v2/all
You can also search for a specific country(Case Insensitive).
https://restcountries.eu/rest/v2/name/{name}
For Example, if you want to search Pakistan this should be your URL.
https://restcountries.eu/rest/v2/capital/pakistan
You will get a JSON Resonance in Return
[{"name":"Pakistan","topLevelDomain":[".pk"],"alpha2Code":"PK","alpha3Code":"PAK","callingCodes":["92"],"capital":"Islamabad","altSpellings":["PK","Pākistān","Islamic Republic of Pakistan","Islāmī Jumhūriya'eh Pākistān"],"region":"Asia","subregion":"Southern Asia","population":194125062,"latlng":[30.0,70.0],"demonym":"Pakistani","area":881912.0,"gini":30.0,"timezones":["UTC+05:00"],"borders":["AFG","CHN","IND","IRN"],"nativeName":"Pakistan","numericCode":"586","currencies":[{"code":"PKR","name":"Pakistani rupee","symbol":"₨"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ur","iso639_2":"urd","name":"Urdu","nativeName":"اردو"}],"translations":{"de":"Pakistan","es":"Pakistán","fr":"Pakistan","ja":"パキスタン","it":"Pakistan","br":"Paquistão","pt":"Paquistão","nl":"Pakistan","hr":"Pakistan","fa":"پاکستان"},"flag":"https://restcountries.eu/data/pak.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"PAK"}]
The flag image URL is in the "flag" key.
Source: https://restcountries.eu/
精彩评论