🌎
country-info
  • Welcome!
  • Quick Start
  • Changelog
  • Reference
    • Functions
      • Get Continent Information
      • Get Country Information
      • Get All Countries Information
      • Get Country by Top-Level Domain
      • Search Countries
    • Function Signatures
    • Testing
Powered by GitBook
On this page

Was this helpful?

  1. Reference
  2. Functions

Get Country Information

You can use the getCountryInfo function to retrieve information about a specific country. This function takes the country name as input and optionally an array of specific fields to retrieve. If no specific fields are provided, all available data for the country will be returned.

const { getCountryInfo } = require('countrys-info');

// Get information about a specific country
const countryData = getCountryInfo('Afghanistan');
console.log(countryData);

// Get a specific field of a country
const capitalEn = getCountryInfo('China', 'capital_en');
console.log(capitalEn);

// Get multiple fields of a country
const countryFields = getCountryInfo('China', ['capital_en', 'code_2', 'tld']);
console.log(countryFields);
PreviousGet Continent InformationNextGet All Countries Information

Last updated 1 year ago

Was this helpful?