<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zayed Hossain</title>
    <description>The latest articles on DEV Community by Zayed Hossain (@zayedhossain120).</description>
    <link>https://dev.to/zayedhossain120</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2279580%2Fa157755b-1a24-4d30-906e-f537f226afeb.png</url>
      <title>DEV Community: Zayed Hossain</title>
      <link>https://dev.to/zayedhossain120</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zayedhossain120"/>
    <language>en</language>
    <item>
      <title>Country Data API Free npm Worldwide</title>
      <dc:creator>Zayed Hossain</dc:creator>
      <pubDate>Thu, 23 Jan 2025 07:24:50 +0000</pubDate>
      <link>https://dev.to/zayedhossain120/unlock-full-stack-potential-with-the-country-data-api-npm-5ap2</link>
      <guid>https://dev.to/zayedhossain120/unlock-full-stack-potential-with-the-country-data-api-npm-5ap2</guid>
      <description>&lt;p&gt;Are you building a global application that requires reliable and structured data about countries, states, and cities? Introducing Country Data API, a lightweight and easy-to-use npm package designed to simplify your development process. With this package, you can access country-specific details, state and city data, and much more — all in a few lines of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Country Data API?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Comprehensive Data: Access a wealth of information about countries, states, and cities in a single library.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ease of Use: The API is designed with simplicity in mind, making it ideal for developers at all levels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lightweight: No bloated dependencies, ensuring quick installation and execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Retrieve a list of all countries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get country names and details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fetch states by country name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access city data by state names.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To get started, install the package via npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install country-data-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to Use the Country Data API
&lt;/h2&gt;

&lt;p&gt;Below are some common use cases with code examples to help you integrate the package into your project seamlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Get All Countries
&lt;/h2&gt;

&lt;p&gt;Fetch a list of all countries with this simple method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getAllCountries } from 'country-data-api';

const countries = getAllCountries();
console.log(countries);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Get All Country Names
&lt;/h2&gt;

&lt;p&gt;Need just the names of the countries? This method has you covered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getAllCountryNames } from 'country-data-api';

const countryNames = getAllCountryNames();
console.log(countryNames);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Get Country Details by Name
&lt;/h2&gt;

&lt;p&gt;Retrieve detailed information about a specific country by its name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getCountryDetailsByName } from 'country-data-api';

const countryDetails = getCountryDetailsByName('Bangladesh');
console.log(countryDetails);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Get States by Country Name
&lt;/h2&gt;

&lt;p&gt;Fetch a list of states within a specific country:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getStatesByCountryName } from 'country-data-api';

const statesInCountry = getStatesByCountryName('Bangladesh');
console.log(statesInCountry);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Get Cities by State Names
&lt;/h2&gt;

&lt;p&gt;Easily fetch cities within a state by passing a state name or an array of state names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { getCitiesByStateNames } from 'country-data-api';

// Get cities by a single state name
const citiesInState = getCitiesByStateNames('Dhaka');
console.log(citiesInState);

// Get cities by an array of state names
const citiesInStates = getCitiesByStateNames(['Dhaka', 'Chittagong']);
console.log(citiesInStates);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-World Applications
&lt;/h2&gt;

&lt;p&gt;The Country Data API is perfect for use in applications like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;E-commerce Platforms: Display country and state dropdowns during checkout.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Travel Websites: Show detailed information about destinations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Educational Tools: Create geography-based learning apps.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Country Data API is the ultimate tool for developers building location-aware applications. Its simplicity and powerful features make it a must-have for anyone working with geographical data.&lt;/p&gt;

&lt;p&gt;So, what are you waiting for? Install the Country Data API and take your applications to the next level today!&lt;/p&gt;

&lt;p&gt;Have questions or feedback? Drop them in the comments below. Let’s build something amazing together!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
