<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Investors Heaven</title>
    <description>The latest articles on DEV Community by Investors Heaven (@investors_heaven_6798cea9).</description>
    <link>https://dev.to/investors_heaven_6798cea9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3701253%2Ff5bdcd72-1396-460b-a32b-ad78129b8256.png</url>
      <title>DEV Community: Investors Heaven</title>
      <link>https://dev.to/investors_heaven_6798cea9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/investors_heaven_6798cea9"/>
    <language>en</language>
    <item>
      <title>I indexed 13M places to calculate real metro populations. Turns out 34.6M people live within 30 miles of Tokyo.</title>
      <dc:creator>Investors Heaven</dc:creator>
      <pubDate>Fri, 09 Jan 2026 00:51:06 +0000</pubDate>
      <link>https://dev.to/investors_heaven_6798cea9/i-indexed-13m-places-to-calculate-real-metro-populations-turns-out-346m-people-live-within-30-5b7</link>
      <guid>https://dev.to/investors_heaven_6798cea9/i-indexed-13m-places-to-calculate-real-metro-populations-turns-out-346m-people-live-within-30-5b7</guid>
      <description>&lt;p&gt;Here's what I mean by "real" metro population:&lt;/p&gt;

&lt;p&gt;Tokyo's official city population: &lt;strong&gt;9.7 million&lt;/strong&gt;(city center - 23 wards)&lt;/p&gt;

&lt;p&gt;But if you draw a 30-mile circle around Tokyo and count every city, town, and populated place inside it? &lt;strong&gt;34.6 million people&lt;/strong&gt; across 49 cities.&lt;/p&gt;

&lt;p&gt;That's 84% of Canada's entire population, living within a 31-mile radius of one point.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea: Everything is a place
&lt;/h2&gt;

&lt;p&gt;I kept hitting the same problem building apps with geographic data. Want to calculate the distance from New York City to Lake Tahoe? Not city to city - from a &lt;strong&gt;city&lt;/strong&gt; to a &lt;strong&gt;lake&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Most APIs can't do this. Cities live in one database, lakes in another, mountains somewhere else. You'd need multiple services and manual coordinate math.&lt;/p&gt;

&lt;p&gt;So I built something different. What if cities, lakes, mountains, airports, parks - all 13 million of them - lived in the same system? Same search, same filters, same calculations.&lt;/p&gt;

&lt;p&gt;The breakthrough: &lt;strong&gt;feature classes&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wait - what's a feature class?
&lt;/h2&gt;

&lt;p&gt;Before I can query anything, I need to know what types of features exist. So the API has a discovery endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://cities-api10.p.rapidapi.com/feature-classes"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-rapidapi-key: MY_API_KEY"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-rapidapi-host: cities-api10.p.rapidapi.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;P&lt;/strong&gt; - Populated places (cities, towns)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;T&lt;/strong&gt; - Terrain (mountains, valleys, hills)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;H&lt;/strong&gt; - Hydrographic (lakes, rivers, streams)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S&lt;/strong&gt; - Spots (airports, ports, stations)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L&lt;/strong&gt; - Landmarks (parks, monuments, buildings)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A&lt;/strong&gt; - Administrative (countries, regions)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now I know P = cities. That's what I need for the metro calculation.&lt;/p&gt;

&lt;p&gt;(For the rest of the examples, I'll just show the endpoint URLs - they all use the same RapidAPI headers.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1: Tokyo metro population
&lt;/h2&gt;

&lt;p&gt;Step 1: Find Tokyo&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places?q=Tokyo&amp;amp;country=JP&amp;amp;class=P&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Returns ID: 1850147, Population: 9,733,276&lt;/p&gt;

&lt;p&gt;Step 2: Get metro area&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places/1850147/metro-area?radius=50&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(API uses kilometers. Need miles?)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/convert/distance?value=50&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Returns: &lt;strong&gt;31.07 miles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Metro area results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Total population&lt;/strong&gt;: 34,601,651&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cities included&lt;/strong&gt;: 49 (Yokohama, Kawasaki, Saitama, Chiba, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Radius&lt;/strong&gt;: 50km (31 miles)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The API automatically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Found all populated places within 50km&lt;/li&gt;
&lt;li&gt;Aggregated their populations&lt;/li&gt;
&lt;li&gt;Returned the breakdown&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Try getting that number from Wikipedia. You'd have to manually add up dozens of cities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2: Distance from a city to a lake
&lt;/h2&gt;

&lt;p&gt;Let's flip to a different feature class. I want the distance from NYC to Lake Tahoe. Remember that this is geolocation, it is straight line distance, not driving distance.&lt;/p&gt;

&lt;p&gt;Find Lake Tahoe:&lt;br&gt;
&lt;code&gt;/places?q=Lake%20Tahoe&amp;amp;country=US&amp;amp;class=H&lt;/code&gt; → ID: 5364686&lt;/p&gt;

&lt;p&gt;(class=H = Hydrographic features. Found it from &lt;code&gt;/feature-classes&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Calculate distance:&lt;br&gt;
&lt;code&gt;/places/distance?from=5128581&amp;amp;to=5364686&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Result: &lt;strong&gt;3,884.8 km&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Convert to miles:&lt;br&gt;
&lt;code&gt;/convert/distance?value=3884.8&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Result: &lt;strong&gt;2,413 miles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Populated place (P) to Hydrographic feature (H). Same distance endpoint. The API doesn't care about categories - both are places with coordinates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 3: Mountains near a lake
&lt;/h2&gt;

&lt;p&gt;I want mountains within 20km of Lake Tahoe.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places/5364686/nearby?class=T&amp;amp;featureCode=MT&amp;amp;radius=20&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Wait - what's &lt;code&gt;featureCode=MT&lt;/code&gt;? That's a more specific filter within the Terrain class. Check it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/feature-codes?class=T&lt;/code&gt; → Shows MT (mountain), HLL (hill), VAL (valley), etc.&lt;/p&gt;

&lt;p&gt;Results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shakespeare Point: 8.5 km&lt;/li&gt;
&lt;li&gt;Eagle Rock: 11.1 km&lt;/li&gt;
&lt;li&gt;South Camp Peak: 13.3 km&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Convert to miles:&lt;br&gt;
&lt;code&gt;/convert/distance?value=8.5&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt; → &lt;strong&gt;5.28 mi&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;/convert/distance?value=11.1&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt; → &lt;strong&gt;6.90 mi&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;/convert/distance?value=13.3&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt; → &lt;strong&gt;8.26 mi&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the same &lt;code&gt;/nearby&lt;/code&gt; endpoint. I used it to find Terrain near Hydrographic by just changing the class filter. No special relationship needed - it just works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 4: Airports near mountains
&lt;/h2&gt;

&lt;p&gt;Real use case: ski trip planning. I need airports near Mount Everest.&lt;/p&gt;

&lt;p&gt;Find Everest:&lt;br&gt;
&lt;code&gt;/places?q=Mount%20Everest&amp;amp;class=T&amp;amp;country=NP&lt;/code&gt; → ID: 1283416&lt;/p&gt;

&lt;p&gt;Find nearby airports:&lt;br&gt;
&lt;code&gt;/places/1283416/nearby?class=S&amp;amp;featureCode=AIRP&amp;amp;radius=200&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(class=S = Spots, which includes airports. Check &lt;code&gt;/feature-codes?class=S&lt;/code&gt; to see all codes.)&lt;/p&gt;

&lt;p&gt;Results (in km):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tenzing-Hillary Airport: 38.6 km&lt;/li&gt;
&lt;li&gt;Phaplu Airport: 62.1 km&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Convert to miles:&lt;br&gt;
&lt;code&gt;/convert/distance?value=38.6&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt; → &lt;strong&gt;23.98 mi&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;/convert/distance?value=62.1&amp;amp;from=km&amp;amp;to=mi&lt;/code&gt; → &lt;strong&gt;38.59 mi&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Terrain (mountain) → Spots (airports). Different classes, same proximity search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 5: Where does your city rank globally?
&lt;/h2&gt;

&lt;p&gt;San Francisco's population rank:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places?q=San%20Francisco&amp;amp;country=US&amp;amp;class=P&lt;/code&gt; → Get ID&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places/{id}/population-rank&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Returns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Global rank&lt;/strong&gt;: #665 out of 472,412 cities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;US rank&lt;/strong&gt;: #21&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Percentile&lt;/strong&gt;: 99.86%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try doing that with typical city APIs. You can't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 6: High-altitude lakes
&lt;/h2&gt;

&lt;p&gt;Say I want lakes in Switzerland above 1,500m elevation:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/places?country=CH&amp;amp;class=H&amp;amp;featureCode=LK&amp;amp;minElevation=1500&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I'm combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Geographic filter (country)&lt;/li&gt;
&lt;li&gt;Feature class (Hydrographic)&lt;/li&gt;
&lt;li&gt;Specific type (lake)&lt;/li&gt;
&lt;li&gt;Elevation filter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Found: Spilauer See at 1,837m&lt;/p&gt;

&lt;p&gt;Convert elevation to feet:&lt;br&gt;
&lt;code&gt;/convert/elevation?value=1837&amp;amp;from=m&amp;amp;to=ft&lt;/code&gt; → &lt;strong&gt;6,027 ft&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The agnostic model means you can combine filters however you want - the API doesn't have predefined "use cases." You compose your own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern
&lt;/h2&gt;

&lt;p&gt;Here's how you discover and query anything:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check available classes: &lt;code&gt;/feature-classes&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Pick your class: P, T, H, S, L, or A&lt;/li&gt;
&lt;li&gt;Optionally get specific: &lt;code&gt;/feature-codes?class=X&lt;/code&gt; for detailed types&lt;/li&gt;
&lt;li&gt;Query with class: &lt;code&gt;/places?class=X&amp;amp;featureCode=Y&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use any endpoint: distance, nearby, metro-area, population-rank - all accept any class&lt;/li&gt;
&lt;li&gt;Convert units as needed: &lt;code&gt;/convert/distance&lt;/code&gt;, &lt;code&gt;/convert/elevation&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Same endpoints, same filters, same logic. Just change the class parameter.&lt;/p&gt;

&lt;p&gt;This unlocks combinations that weren't possible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metro population for any city: &lt;code&gt;/places/{id}/metro-area?radius=50&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Distance from city to lake: &lt;code&gt;/places/distance?from={city}&amp;amp;to={lake}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Mountains near lakes: &lt;code&gt;/places/{lake_id}/nearby?class=T&amp;amp;featureCode=MT&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Airports near mountains: &lt;code&gt;/places/{mountain_id}/nearby?class=S&amp;amp;featureCode=AIRP&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;High-elevation lakes: &lt;code&gt;/places?class=H&amp;amp;featureCode=LK&amp;amp;minElevation=1500&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Convert any distance or elevation: &lt;code&gt;/convert/distance&lt;/code&gt;, &lt;code&gt;/convert/elevation&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What you could build with the API (among many things)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Demographic tools&lt;/strong&gt; - Calculate real market sizes using metro area aggregation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Travel planners&lt;/strong&gt; - Find airports near mountains, cities near lakes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real estate apps&lt;/strong&gt; - Population ranks, metro area growth analysis&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logistics tools&lt;/strong&gt; - Find ports, airports, cities along routes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern is the same: check &lt;code&gt;/feature-classes&lt;/code&gt;, pick what you need, compose your query.&lt;/p&gt;

&lt;p&gt;It's on RapidAPI now with 84 endpoints covering places, countries, timezones, postal codes, and unit conversions. Free tier available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docs&lt;/strong&gt;: &lt;a href="https://hthought.github.io/cities-api-docs" rel="noopener noreferrer"&gt;https://hthought.github.io/cities-api-docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What would you calculate with this? What metro areas would you compare? Drop a comment.&lt;/p&gt;

</description>
      <category>api</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
