Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
api-population-io
Advanced tools
Simple universal Javascript Wrapper around Population.IO API
$ yarn add api-population-io
$ npm install --save api-population-io
Import the module in your code
import populationIO from 'api-population-io';
const populationIO = require('api-population-io');
Then, use the module to perform your request to PopulationIO API
You can either use promises..
populationIO.lifeExpectancy.total({
sex: 'male',
country: 'United Kingdom',
dob: '1970-01-01'
})
.then((data) => {
console.log('total_life_expectancy:', data.total_life_expectancy);
})
.catch((err) => {
console.log(err.detail);
});
.. or callbacks, by passing the function as the second parameter
populationIO.lifeExpectancy.total({
sex: 'male',
country: 'United Kingdom',
dob: '1970-01-01'
}, (err, data) => {
if (err) {
console.log(err.detail);
} else {
console.log('total_life_expectancy:', data.total_life_expectancy);
}
});
Returns a list of all countries in the statistical dataset
populationIO.countries([callback])
These are also the valid input values to the various 'country' parameters across the remaining API.
The world population rank is defined as the position of someone's birthday among the group of living people of the same sex and country of origin, ordered by date of birth decreasing. The last person born is assigned rank #1.
Calculates the world population rank of a person with the given date of birth, sex and country of origin as of today
populationIO.wpRank.today(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)Calculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date
populationIO.wpRank.onDate(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)date
- type string:date
- the date to calculate the rank forCalculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by the person's age.
populationIO.wpRank.whenAged(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)age
- type string:offset
- the given ageCalculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by an offset towards the past from today
populationIO.wpRank.ago(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)offset
- type string:offset
- how much time back in the past to calculate the rank forCalculates the world population rank of a person with the given date of birth, sex and country of origin on a certain date as expressed by an offset towards the future from today
populationIO.wpRank.in(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)offset
- type string:offset
- how much time in the future to calculate the rank forCalculates the day on which a person with the given date of birth, sex and country of origin has reached (or will reach) a certain world population rank.
populationIO.wpRank.whenRanked(data, [callback])
Requires a data
object as the first parameter with the following properties:
dob
- type string:date
- the subject's date of birthsex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)rank
- type int
- the rank to calculate the date forCalculate remaining life expectancy of a person with given sex, country, and age at a given point in time.
populationIO.lifeExpectancy.remaining(data, [callback])
Requires a data
object as the first parameter with the following properties:
sex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)date
- type string:date
- the point in time to calculate the remaining life expectancy atage
- type string:offset
- the subject's age at the given point in timeCalculate total life expectancy of a person with given sex, country, and date of birth
populationIO.lifeExpectancy.total(data, [callback])
Requires a data
object as the first parameter with the following properties:
sex
- type string
- the subject's sexcountry
- type string
- the subject's country of birth (World
for all)dob
- type string:date
- the subject's date of birthRetrieve population table for all countries and a specific age group in the given year
populationIO.population.byAgeAndYear(data, [callback])
Requires a data
object as the first parameter with the following properties:
age
- type int
- the age to retrieve the population table foryear
- type int
- the year to retrieve the population table forRetrieve population table for a specific age group in the given year and country
populationIO.population.byAgeAndYearAndCountry(data, [callback])
Requires a data
object as the first parameter with the following properties:
age
- type int
- the age to retrieve the population table foryear
- type int
- the year to retrieve the population table forcountry
- type string
- the country to retrieve the population table forRetrieve population table for all countries and a specific age group in the given year
populationIO.population.byYearAndCountry(data, [callback])
Requires a data
object as the first parameter with the following properties:
year
- type int
- the year to retrieve the population table forcountry
- type string
- the country to retrieve the population table forRetrieve population tables for a specific age group in the given country
populationIO.population.byAgeAndCountry(data, [callback])
Requires a data
object as the first parameter with the following properties:
age
- type int
- the age to retrieve the population table forcountry
- type string
- the country to retrieve the population table forDetermines total population for a given country on a given date
populationIO.population.byCountryAndDate(data, [callback])
Requires a data
object as the first parameter with the following properties:
country
- type string
- the country to retrieve the population table fordate
- type string:date
- the date to determine the total population forDetermines total population for a given country with separate results for today and tomorrow
populationIO.population.todayAndTomorrow(data, [callback])
Requires a data
object as the first parameter with the following properties:
country
- type string
- the country to retrieve the population table forRetrieves the mortality distribution tables for the given country, sex and age
populationIO.mortalityDistribution.today(data, [callback])
Requires a data
object as the first parameter with the following properties:
country
- type string
- the country to retrieve the distribution forsex
- type string
- the sex to retrieve the distribution forage
- type string:offset
- the age to retrieve the population table forSee something that could be improved ? Open an issue or contribute !
MIT
FAQs
JavaScript higher-level wrapper around population.io API
The npm package api-population-io receives a total of 1 weekly downloads. As such, api-population-io popularity was classified as not popular.
We found that api-population-io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.