{"id":2961,"date":"2026-11-18T20:02:33","date_gmt":"2026-11-18T19:02:33","guid":{"rendered":"https:\/\/extendsclass.com\/blog\/?p=2961"},"modified":"2026-11-18T19:59:01","modified_gmt":"2026-11-18T18:59:01","slug":"geolocation-apis-explained-what-data-they-return","status":"publish","type":"post","link":"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return","title":{"rendered":"Geolocation APIs explained: What data they return"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">It&#8217;s obvious that if you visit a weather site, your city will be highlighted even before you start typing. If you make purchases online, your checkout page automatically switches the payment currency to the appropriate one. Behind the scenes of both cases, there was the activity of a geolocation API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While developers use such services all the time, not everyone knows which information they return and which part of it is credible. In this article, you will learn about the two types of geolocation APIs, which information they return, and the reliability of this information.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_47_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"ez-toc-toggle-icon-1\"><label for=\"item-6b045c476b575\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-6b045c476b575\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#Two_different_services_have_one_common_name\" title=\"Two different services have one common name\">Two different services have one common name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#What_information_does_browser_geolocation_API_return\" title=\"What information does browser geolocation API return?\">What information does browser geolocation API return?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#What_information_does_IP_geolocation_API_return\" title=\"What information does IP geolocation API return?\">What information does IP geolocation API return?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#Comparing_information_obtained_from_API_with_information_obtained_by_quick_look-up\" title=\"Comparing information obtained from API with information obtained by quick look-up\">Comparing information obtained from API with information obtained by quick look-up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#Limitations_and_privacy\" title=\"Limitations and privacy\">Limitations and privacy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/extendsclass.com\/blog\/geolocation-apis-explained-what-data-they-return\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Two_different_services_have_one_common_name\"><\/span><strong>Two different services have one common name<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;Geolocation API&#8221; sounds simple. But in this case, it refers to two completely different services.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first option is the built-in browser API accessible via navigator.geolocation, which estimates the location of the device using GPS, Wi-Fi networks, or cell towers. It works only if a user gives permission, and only over a <a href=\"https:\/\/www.cloudflare.com\/learning\/ssl\/what-is-https\/\">secure HTTPS connection<\/a>. Such APIs are found in almost all popular web browsers today.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The second option is a web service like MaxMind, IPinfo, or ipapi providing an estimate of where the specified IP address is used. In such a situation, there&#8217;s no need for users to give any permissions, as an estimation is made using databases that match IP address ranges to locations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One asks the device about its location. Another asks a database about the location related to an IP address.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_information_does_browser_geolocation_API_return\"><\/span><strong>What information does browser geolocation API return?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After successfully getting the user&#8217;s permission, the API returns the following structure:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>timestamp;<\/li>\n\n\n\n<li>coords, which in turn contain:\n<ul class=\"wp-block-list\">\n<li>longitude and latitude in decimal degrees;<\/li>\n\n\n\n<li>accuracy in meters, representing the range in which the location estimate is correct;<\/li>\n\n\n\n<li>altitude and altitudeAccuracy, heading, and speed (frequently null on laptops and desktops).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In case of receiving the PERMISSION_DENIED error code 1 (if the user doesn&#8217;t want to give permission), you should have a backup plan in order to handle such an event.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_information_does_IP_geolocation_API_return\"><\/span><strong>What information does IP geolocation API return?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, it returns a JSON object that contains a bit more context and has slightly lower accuracy compared with the browser API. Such an object usually consists of the following information:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>country (also, usually there&#8217;s a two-letter ISO country code);<\/li>\n\n\n\n<li>region\/state;<\/li>\n\n\n\n<li>city;<\/li>\n\n\n\n<li>postal code;<\/li>\n\n\n\n<li>coordinates (approximate latitude and longitude);<\/li>\n\n\n\n<li>time zone.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Also, such API providers frequently add the following information about networks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>autonomous system number;<\/li>\n\n\n\n<li>network name of the Internet Service Provider or organization;<\/li>\n\n\n\n<li>sometimes information about connection type (mobile, residential, business).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">And also, depending on the subscription plan of the service, some services add information about:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the usage of a Virtual Private Network (VPN) service;<\/li>\n\n\n\n<li>proxy service;<\/li>\n\n\n\n<li>Tor relay node (which hides a user&#8217;s true location);<\/li>\n\n\n\n<li>hosting provider.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Keep in mind that the coordinates returned in response to IP-based services won&#8217;t refer to any street or specific place. Usually, they correspond to the midpoint of a city or a postal area. Moreover, some providers add additional fields that demonstrate the range (accuracy) of this information, and some providers also add a confidence value field. Also, in this case, country information is very reliable, and city information is not so accurate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Comparing_information_obtained_from_API_with_information_obtained_by_quick_look-up\"><\/span><strong>Comparing information obtained from API with information obtained by quick look-up<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First of all, before starting to use any particular API, you should compare the information returned with a quick manual check by using the same IP address in an IP address location lookup tool such as the one provided by <a href=\"https:\/\/surfshark.com\/ip-lookup\">Surfshark<\/a>. Make sure that both providers give you the same ISP and country. If the city information differs, it means that the IP belongs to a mobile network or corporate networks routing traffic using one remote IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And also, you can quickly do the following tests using a terminal:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>run whois in order to determine the owner of the IP address;<\/li>\n\n\n\n<li>do a reverse DNS lookup (using dig -x or nslookup commands), as hostnames sometimes include city or airport names;<\/li>\n\n\n\n<li>make requests to the provider directly via curl and parse the obtained JSON (pay attention to accuracy and confidence fields).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can test a limited number of addresses that you know for sure, like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>your work office connection;<\/li>\n\n\n\n<li>your mobile hotspot (if you are on a smartphone);<\/li>\n\n\n\n<li>VPN server.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You will quickly understand where your API provides you with reliable information and where you get just guesses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Limitations_and_privacy\"><\/span><strong>Limitations and privacy<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">IP address information can change over time. Address blocks become reassigned. Mobile providers distribute their addresses among large geographical regions using carrier-grade NAT. And services like Virtual Private Network and Apple&#8217;s iCloud Private Relay intentionally hide the real IP address of users from external applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Privacy policies are important too. According to GDPR, an IP address can qualify as personally identifiable information. Geographical location of a device is considered sensitive personal information in many jurisdictions. Don&#8217;t collect more data than your feature requires. You should avoid storing exact coordinates if your app works with the city or country.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Geolocation API returns more information than a dot on the map. Browser geolocation provides you with precise coordinates along with an accuracy value, but in exchange, it requests permission. IP-based services provide you with information about a country, city, and time zone. Read each field carefully with its accuracy in mind, test the results manually, and consider geolocation information as just another hint and nothing else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s obvious that if you visit a weather site, your city will be highlighted even before you start typing. If you make purchases online, your checkout page automatically switches the payment currency to the appropriate one. Behind the scenes of both cases, there was the activity of a geolocation API. While developers use such services [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2962,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-2961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/2961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/comments?post=2961"}],"version-history":[{"count":1,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/2961\/revisions"}],"predecessor-version":[{"id":2963,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/2961\/revisions\/2963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media\/2962"}],"wp:attachment":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media?parent=2961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/categories?post=2961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/tags?post=2961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}