Gathering detailed insights and metrics for worldcities
Gathering detailed insights and metrics for worldcities
npm install worldcities
Typescript
Module System
Node Version
NPM Version
TypeScript (51.27%)
JavaScript (45.02%)
Shell (3.72%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
44,111
Last Day
9
Last Week
79
Last Month
344
Last Year
7,739
10 Stars
59 Commits
5 Forks
2 Watching
14 Branches
3 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.8
Package Id
worldcities@0.1.8
Unpacked Size
7.29 MB
Size
2.07 MB
File Count
528
NPM Version
9.5.1
Node Version
14.19.0
Publised On
15 Mar 2023
Cumulative downloads
Total Downloads
Last day
-77.5%
9
Compared to previous day
Last week
-43.2%
79
Compared to previous week
Last month
2.4%
344
Compared to previous month
Last year
-33.7%
7,739
Compared to previous year
24,343 world cities and 252 countries.
A convenient wrapper for the GeoNames database of world cities data.
The data from the GeoNames tab seperated values files are parsed and normalized into a JSON object for quick lookup and distance calculations. The data for each city's country is also normalized, indexed by ISO_3166-1 country code, paired with the country's flag's SVG, GeoJSON of its boundaries, and relative URL to Wikipedia page.
1const WorldCities = require('worldcities'); 2const city = WorldCities.getNearestCity(5.42282298420212, 100.33753796627954); 3 4// City { 5// latitude: 5.41123, 6// longitude: 100.33543, 7// name: 'George Town', 8// population: 300000, 9// timezone: 'Asia/Kuala_Lumpur', 10// country: Country { 11// areaSquareMeters: 329750, 12// callingCode: '60', 13// capital: 'Kuala Lumpur', 14// continent: 'AS', 15// countryCode: 'MY', 16// countryCode3: 'MYS', 17// currencyCode: 'MYR', 18// currencyName: 'Ringgit', 19// languages: [ 20// 'ms-MY', 'en', 21// 'zh', 'ta', 22// 'te', 'ml', 23// 'pa', 'th' 24// ], 25// name: 'Malaysia', 26// neighbors: [ 'BN', 'TH', 'ID' ], 27// population: 31528585, 28// postalCodeRegExp: '^(\\d{5})$', 29// tld: '.my', 30// wikipedia: 'Malaysia', 31// geoJSON: undefined, 32// flagSVG: undefined 33// } 34// }
1const WorldCities = require('worldcities'); 2const city = WorldCities.getNearestLargeCity(17.076480407330514, -101.3674415353851);
1const city = WorldCities.getByName('Tokyo');
1const cities = WorldCities.getByName('nEw yOrK'); 2assert.equal(cities.length, 3);
Retrieve the country data by querying for it by the 2 letter country code. The second argument returns the Country with full data, including geoJSON and flag SVG.
1const country = WorldCities.getCountry('NZ', true); 2fs.writeFileSync('nz.flag.svg', country.flagSVG);
The city data includes the IANA timezone ID in string format; ie. "America/Los_Angeles". To use these to localize dates and times to the city, it's highly recommended to use the Moment Timezone library.
For example, to convert a UNIX timestamp to a localized date time string:
1const moment = require('moment-timezone'); 2 3moment(Math.floor(Date.now() / 1000), 'X') 4 .tz('America/Los_Angeles') 5 .format('dddd, MMMM Do YYYY, h:mm:ss a z'); 6 7// "Friday, May 1st 2020, 5:52:11 am PDT"
GeoJSON objects can be visualized nicely in the http://geojson.io/ UI.
Google Maps also supports using GeoJSON as a "Data Layer" via the API.
All of the data is also available in a compact SQLite file. It is in the source repository, but not included in the package to keep size reasonable.
[https://raw.githubusercontent.com/OpenDataFormats/worldcities/master/data/worldcities.sqlite]
City and country data:
Flag SVG data
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 2/15 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More