1.0.5 • Published 9 months ago

geographyx-api v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

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 bougsoon.studio@gmail.com

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago