npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geographyx-api

v1.0.5

Published

This JavaScript API allows you to retrieve detailed information about countries worldwide. It utilizes data from public sources to provide a variety of information, such as population, capital, currency, spoken languages, region code, and more.

Downloads

8

Readme

GeographyX API

Country Information API

This JavaScript API allows you to retrieve detailed information about countries worldwide. It utilizes data from public sources to provide a variety of information, such as population, capital, currency, spoken languages, region code, and more. Currency API version :

  • v.1.0.5

News fonctionality

  • Weather for Country
  • Verification Token

You can use GeographyX API with Node Package Manager, ==> npm install geographyx-api


## Usage

To use this API, follow the steps below:

1. Include the `api.geographyx.js` file in your project:

```html
<script type="module">
    import { Auth, getCountryInfo, getAllCountries, fetchCountryData, whatCountry } from "../geographyx/api/api.geographyx.js";
</script>
  1. Use the API functions to retrieve country information:
        import { Auth, VerifAuth, getCountryInfo, getAllCountries, fetchCountryData, whatCountry, weatherCountry } from "../geographyx/api/api.geographyx.js";
        
        async function main() {
            try {
                // Verification token
                const MyToken = await Auth("AdminTest-Token"); 

                // Use VerifAuth to verify a token =>
                const TokenToVerif = await VerifAuth("AdminTest-Token");
        
                // Useful infos for each country =>
                const capital = await getCountryInfo('Switzerland', 'capital');
                // Show in Console
                console.log(capital);
        
                // All useful infos for country =>
                const infos = await getCountryInfo('Switzerland');
                // Show in Console
                console.log(infos);
        
                // All Countries =>
                const allCountries = getAllCountries(await fetchCountryData());
                // Show in Console
                console.log(allCountries);
        
                // Countries with specific field value =>
                const countriesWithLanguages = await whatCountry('initial', 'CH');
                // Show in console
                console.log(countriesWithLanguages);

                // Weather data for a country =>
                const weatherData = await weatherCountry('Switzerland');
                if (weatherData) {
                    weatherData.forEach(weather => {
                        console.log("Temperature:", weather.temperature);
                        console.log("Description:", weather.description);
                        console.log("Humidity:", weather.humidity);
                        console.log("Pressure:", weather.pressure);
                        console.log("Wind Speed:", weather.windSpeed);
                    });
                }

            } catch (error) {
                console.error(error.message);
            }
        }
        main();

Get a free token

You can get a free token at : https://geographyx-api.web.app/get/token or use the free public token : FREE_TOKEN

Available Functions

  • const MyToken = await Auth("YOUR_TOKEN");: to use our api, you must have a token, you can get one for free at https://geographyx-api.web.app/get/token, or use the token: "FREE_TOKEN", simply replace YOUR_TOKEN with your token.

  • const TokenToVerif = await VerifAuth("YOUR_TOKEN_YOU_WANT_VERIF");: Use this line to verif a token, remplace YOUR_TOKEN_YOU_WANT_VERIF by a token.

  • getCountryInfo(country, field): Returns detailed information about the specified country along with the specific information requested with field.

  • getCountryInfo(country): Returns all informations about the specified country.

  • getAllCountries(await fetchCountryData()): Returns all countries.

  • whatCountry(field, value): Get the country related to the field and its value.

  • await weatherCountry(country): Get Weather in this country related to the country

Information you can obtain

You can obtain information (field) such as :

  • Population,
  • Capital,
  • Calling Code,
  • Initial,
  • Area,
  • GDP,
  • Languages,
  • Latitude,
  • Longitude,
  • Map,
  • Continent,
  • TimeZone,
  • Flag

Example

        import { Auth, VerifAuth, getCountryInfo, getAllCountries, fetchCountryData, whatCountry, weatherCountry } from "../geographyx/api/api.geographyx.js";
        
        async function main() {
            try {
                // Verification token
                const MyToken = await Auth("AdminTest-Token"); 

                // Use VerifAuth to verify a token =>
                const TokenToVerif = await VerifAuth("AdminTest-Token");
        
                // Useful infos for each country =>
                const capital = await getCountryInfo('Switzerland', 'capital');
                // Show in Console
                console.log(capital);
        
                // All useful infos for country =>
                const infos = await getCountryInfo('Switzerland');
                // Show in Console
                console.log(infos);
        
                // All Countries =>
                const allCountries = getAllCountries(await fetchCountryData());
                // Show in Console
                console.log(allCountries);
        
                // Countries with specific field value =>
                const countriesWithLanguages = await whatCountry('initial', 'CH');
                // Show in console
                console.log(countriesWithLanguages);

                // Weather data for a country =>
                const weatherData = await weatherCountry('Switzerland');
                if (weatherData) {
                    weatherData.forEach(weather => {
                        console.log("Temperature:", weather.temperature);
                        console.log("Description:", weather.description);
                        console.log("Humidity:", weather.humidity);
                        console.log("Pressure:", weather.pressure);
                        console.log("Wind Speed:", weather.windSpeed);
                    });
                }

            } catch (error) {
                console.error(error.message);
            }
        }
        main();

Available for everyone

Once all features and bugs are fixed, GeographyX API will be available for all modes on Github. For the moment, GeographyX is available on npmjs.com and via the command - npm install geographyx-api

Disclaimer

This API uses data from third-party sources and may not always be up-to-date. Please verify the accuracy of the information provided before using it in a production project.

License

This project is licensed under the MIT License.

Contract

You can contact us by email, at [email protected]