Skip to content

nmajor/us-city-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

us-city-data

Officially sourced data for every U.S. city as a tiny no-dependency package.

This package ships a practical city lookup layer built from the same public data pipeline that powers Every City in the USA. Use it to search U.S. cities, look up Census GEOIDs, filter by state or population, and link back to full city profiles with maps, downloads, methodology, and source traceability.

What's Included

  • 19,483 U.S. cities, towns, villages, boroughs, municipalities, and equivalent places.
  • U.S. Census GEOIDs, state names and abbreviations, city slugs, coordinates, area, density, population, growth, and ranks.
  • profileUrl values pointing to full Every City in the USA profile pages.
  • Source metadata with Census and Gazetteer URLs, checksums, counts, and build timestamp.
  • A no-dependency JavaScript API and a small CLI.

Install

npm install us-city-data

You can also use the repository directly:

git clone https://github.com/nmajor/us-city-data.git
cd us-city-data
npm test

JavaScript API

import {
  allCities,
  citiesByState,
  findCities,
  getCityByGeoid,
  getCityBySlug,
  topCitiesByPopulation
} from "us-city-data";

const mesa = getCityBySlug("mesa-az");
const azCities = citiesByState("AZ");
const searchResults = findCities("springfield", { limit: 10 });
const biggestTexasCities = topCitiesByPopulation({ state: "TX", limit: 5 });
const newYork = getCityByGeoid("3651000");

console.log(mesa.profileUrl);
console.log(azCities.length, searchResults.length, biggestTexasCities, newYork);

CLI

npx us-city-data search mesa --state AZ --limit 3
npx us-city-data slug mesa-az --json
npx us-city-data geoid 3651000
npx us-city-data top --state TX --limit 10
npx us-city-data between 50000 100000 --state CA

Data Shape

Each city object uses this shape:

{
  geoid: "0455000",
  name: "Mesa city",
  nameShort: "Mesa",
  state: "AZ",
  stateName: "Arizona",
  slug: "mesa-az",
  placeType: "incorporated_place",
  population: 513656,
  populationYear: 2025,
  lat: 33.399355,
  lon: -111.715968,
  landAreaSqMi: 141.961,
  densityPerSqMi: 3618.289530223089,
  growthSince2020Abs: 9264,
  growthSince2020Pct: 1.8366667195355992,
  nationalPopulationRank: 38,
  statePopulationRank: 3,
  profileUrl: "https://www.everycityintheusa.com/cities/mesa-az/"
}

Data Source

The data is compiled from official U.S. government sources and normalized by Every City in the USA. See data/metadata.json for exact source URLs, checksums, counts, and the build timestamp.

Full profiles, methodology, CSV downloads, and additional official city data are available at Every City in the USA.

Sponsor

If this dataset saves you time, GitHub Sponsors and project support links are configured in .github/FUNDING.yml. The custom project link points to:

https://www.everycityintheusa.com

License

Code is MIT licensed. Data licensing details are in DATA_LICENSE.md.

About

Officially sourced data for every U.S. city as a tiny no-dependency package.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors