How to implement Countries List API in your project

Hello, in this article we will learn how to implement Countries List inside your project (website, android app, etc).

here’s an example of android app:

first, we will use CountriesList library from Github:
github.com/kimoandroid/Countrie…


This content originally appeared on DEV Community and was authored by Karim Abdallah

Hello, in this article we will learn how to implement Countries List inside your project (website, android app, etc).



here's an example of android app:

android app

first, we will use CountriesList library from Github:
github.com/kimoandroid/CountriesList



Why this library

  • Easy to use anywhere.
  • You can add unlimited translation for the same file without editing the main function or use Hardcoded.
  • You can use country_code key to use it in your sytem for calling codes.
  • you can display country name with it's flag easily.



You can easily use the ready api directly by using this link: https://api.encept.co/countries/index.php?lang=en

  • api parameters: lang=ar OR lang=en
  • api response: JSON Encode.
  • JSON response example:
[{
"code":"US",
"calling_code":"+1",
"flag":"🇺🇸",
"name":"United States"
}]



You can use this api directly and call this link from your project and get the JSON response.

Or you can create your api from zero at your own server & use your own link.

First, Download The Library Files That I Mentioned Before From Github: github.com/kimoandroid/CountriesList

This Library is very flexable and easy to use & edit.

Inside Localization folder you will find the translation of the countries name you can add new translation file by creating file called country_[lang symbol].php such as spanish, you will create a file named country_sp.php.

and after that copy all content that inside default_strings.php file 'this is the translation schema'

now if anyone called the api url and put this parameter: 'lang=sp' the api will return the countries list with spanish.



That's all, Follow For More :)


This content originally appeared on DEV Community and was authored by Karim Abdallah


Print Share Comment Cite Upload Translate Updates
APA

Karim Abdallah | Sciencx (2023-05-14T14:21:16+00:00) How to implement Countries List API in your project. Retrieved from https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/

MLA
" » How to implement Countries List API in your project." Karim Abdallah | Sciencx - Sunday May 14, 2023, https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/
HARVARD
Karim Abdallah | Sciencx Sunday May 14, 2023 » How to implement Countries List API in your project., viewed ,<https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/>
VANCOUVER
Karim Abdallah | Sciencx - » How to implement Countries List API in your project. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/
CHICAGO
" » How to implement Countries List API in your project." Karim Abdallah | Sciencx - Accessed . https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/
IEEE
" » How to implement Countries List API in your project." Karim Abdallah | Sciencx [Online]. Available: https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/. [Accessed: ]
rf:citation
» How to implement Countries List API in your project | Karim Abdallah | Sciencx | https://www.scien.cx/2023/05/14/how-to-implement-countries-list-api-in-your-project/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.