{"id":9457,"date":"2024-06-19T17:20:42","date_gmt":"2024-06-19T16:20:42","guid":{"rendered":"https:\/\/www.verificaremails.com\/hlr-lookup-api-for-phone-number-validation\/"},"modified":"2025-07-29T17:51:48","modified_gmt":"2025-07-29T16:51:48","slug":"hlr-lookup-api-for-phone-number-validation","status":"publish","type":"post","link":"https:\/\/www.verificaremails.com\/en\/hlr-lookup-api-for-phone-number-validation\/","title":{"rendered":"HLR Lookup API for phone number validation"},"content":{"rendered":"<p>In this article you will learn how to use the HLR Lookup API to validate phone numbers in real time. You will see how to perform individual validations, mass validations through files and how to automate the processes to create a number validator through the API. We will see several code examples, focusing on some languages such as PHP and JavaScript. Finally we will see how to use the phone number verification API documentation.<\/p>\n<h3 dir=\"ltr\">What is a REST API?<\/h3>\n<p dir=\"ltr\">An <b><br \/>\n<strong>REST API<\/strong><br \/>\n<\/b> (Application Programming Interface Representational State Transfer) is a form of communication between systems using HTTP conventions. Imagine it is a messenger that carries requests and responses between your application and a server. REST APIs are widely used due to their simplicity and efficiency.<\/p>\n<h3 dir=\"ltr\">Main components of a REST API<\/h3>\n<ol>\n<li value=\"1\"><b><br \/>\n<strong>Resources<\/strong><br \/>\n<\/b>They represent data, such as users or products.<\/li>\n<li value=\"2\"><b><br \/>\n<strong>HTTP Verbs<\/strong><br \/>\n<\/b>Methods such as GET, POST, PUT and DELETE to interact with resources.<\/li>\n<li value=\"3\"><b><br \/>\n<strong>Endpoints<\/strong><br \/>\n<\/b>URLs indicating where a specific resource is located.<\/li>\n<li value=\"4\"><b><br \/>\n<strong>Data Format<\/strong><br \/>\n<\/b>Usually JSON or XML.<\/li>\n<\/ol>\n<h3 dir=\"ltr\">Practical Example: Phone Number Verification with HLR Lookup<\/h3>\n<p dir=\"ltr\">Phone number verification using <b><br \/>\n<strong>HLR Lookup<\/strong><br \/>\n<\/b><a href=\"https:\/\/en.wikipedia.org\/wiki\/HLR\" target=\"_blank\" rel=\"nofollow noopener\">(Home Location Register Lookup<\/a>) allows you to know if a number is valid and active. This is useful for companies that want to ensure that their messages reach the right recipients.<\/p>\n<h4 dir=\"ltr\">Verification process<\/h4>\n<ol>\n<li value=\"1\"><b><br \/>\n<strong>You send a request<\/strong><br \/>\n<\/b> with the phone number to the HLR Lookup API.<\/li>\n<li value=\"2\"><b><br \/>\n<strong>The validation API queries<\/strong><br \/>\n<\/b> the HLR database of the telephone operator.<\/li>\n<li value=\"3\"><b><br \/>\n<strong>You receive a response<\/strong><br \/>\n<\/b> indicating the status of the phone number.<\/li>\n<\/ol>\n<h4 dir=\"ltr\">Step-by-step implementation using the verificaremails.com API<\/h4>\n<ol>\n<li value=\"1\"><b><strong>Register<\/strong><br \/>\n<\/b> at <a href=\"https:\/\/www.verificaremails.com\/en\/\">verificaremails.com<\/a> and get your API key.<\/li>\n<li value=\"2\"><b><strong>Sends a GET request<\/strong><br \/>\n<\/b> request to the HLR Lookup validation API.<\/li>\n<\/ol>\n<pre spellcheck=\"false\" data-highlight-language=\"javascript\">curl -X GET \"https:\/\/www.verificaremails.com\/api\/v1\/hlr?phone_number=1234567890\" \r\n-H \"apikey: TU_CLAVE_API\"<\/pre>\n<ol start=\"3\">\n<li value=\"3\"><b><br \/>\n<strong>Interpret the answer<\/strong><br \/>\n<\/b>. An example of a response might be:<\/li>\n<\/ol>\n<pre spellcheck=\"false\" data-highlight-language=\"javascript\">{\r\n\"status\": \"success\",\r\n\"data\": {\r\n\"phone_number\": \"1234567890\",\r\n\"valid\": true,\r\n\"carrier\": \"Movistar\",\r\n\"country\": \"ES\"\r\n}\r\n}<\/pre>\n<p>We can get more information about the phone number in particular if it is a mobile number in the JSON file of the response.<\/p>\n<p><strong>Response format<\/strong><\/p>\n<p>If we go into detail, apart from indicating whether the number is valid or invalid, we can obtain information about the telephone operator, the type of line, the international format of the number&#8230; If you want to know if the number is valid you should look at the IMSI, MCC, MNC and MCCMNC fields. All these checks are performed by the validation api and displayed in the value of the &#8220;reachable&#8221; field.<\/p>\n<h3 dir=\"ltr\">IMSI<\/h3>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">The <b><br \/>\n<strong class=\"editor_editorTextBold__UTGUL\">IMSI<\/strong><br \/>\n<\/b> (International Mobile Subscriber Identity) is a unique number associated with each mobile network user. This number is stored on the SIM card and is used by mobile networks to identify subscribers.<\/p>\n<h3 dir=\"ltr\">IMSI Components<\/h3>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">The IMSI is composed of three parts:<\/p>\n<ol class=\"editor_editorListOl__nODeB\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\"><b><br \/>\n<strong class=\"editor_editorTextBold__UTGUL\">MCC (Mobile Country Code)<\/strong><br \/>\n<\/b>Three-digit code that identifies the subscriber&#8217;s country.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\"><b><br \/>\n<strong class=\"editor_editorTextBold__UTGUL\">MNC (Mobile Network Code)<\/strong><br \/>\n<\/b>Two or three digit code that identifies the mobile network within that country.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"3\"><b><br \/>\n<strong class=\"editor_editorTextBold__UTGUL\">MSIN (Mobile Subscriber Identification Number)<\/strong><br \/>\n<\/b>Unique number that identifies the subscriber within the mobile network.<\/li>\n<\/ol>\n<h3 dir=\"ltr\">MCC and MNC<\/h3>\n<ul class=\"editor_editorListUl__Z78So\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\"><b><strong class=\"editor_editorTextBold__UTGUL\">MCC<\/strong><br \/>\n<\/b>CQI: Each country has a unique CQI. For example, Spain has MCC 214.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\"><b><strong class=\"editor_editorTextBold__UTGUL\">MNC<\/strong><br \/>\n<\/b>The operators within a country have different MNCs. For example, in Spain, Movistar has MNC 07.<\/li>\n<\/ul>\n<h3 dir=\"ltr\">MCCMNC<\/h3>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">The <b><br \/>\n<strong class=\"editor_editorTextBold__UTGUL\">MCCMNC<\/strong><br \/>\n<\/b> is the combination of the MCC and the MNC. It is used to uniquely identify a mobile network in a country. For example, the MCCMNC for Movistar in Spain would be 21407.<\/p>\n<h3 dir=\"ltr\">Phone Number Verification<\/h3>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">To verify if a phone number is true using the IMSI:<\/p>\n<ol class=\"editor_editorListOl__nODeB\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\"><b><strong class=\"editor_editorTextBold__UTGUL\">Obtaining the IMSI<\/strong><br \/>\n<\/b>Extract the IMSI from the SIM card of the phone.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\"><b><strong class=\"editor_editorTextBold__UTGUL\">Analyze the IMSI<\/strong><br \/>\n<\/b>:<\/li>\n<li class=\"editor_editorListItem__O5oI5 editor_editorNestedListitem__It2Oq\" value=\"3\">\n<ul class=\"editor_editorListUl__Z78So\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\">Extract the MCC and MNC from the IMSI.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\">Verify that the MCC corresponds to the expected country.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"3\">Verify that the MNC corresponds to a valid operator in that country.<\/li>\n<\/ul>\n<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"3\"><b><strong class=\"editor_editorTextBold__UTGUL\">Validation<\/strong><br \/>\n<\/b>:<\/li>\n<li class=\"editor_editorListItem__O5oI5 editor_editorNestedListitem__It2Oq\" value=\"4\">\n<ul class=\"editor_editorListUl__Z78So\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\">Check that the MCCMNC exists and is valid.<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\">Ensure that the MSIN is correct and active on the network.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 dir=\"ltr\">Example<\/h3>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">If you have an IMSI 214071234567890, you can break it down like this:<\/p>\n<ul class=\"editor_editorListUl__Z78So\">\n<li class=\"editor_editorListItem__O5oI5\" value=\"1\"><b><strong class=\"editor_editorTextBold__UTGUL\">MCC<\/strong><br \/>\n<\/b>: 214 (Spain)<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"2\"><b><strong class=\"editor_editorTextBold__UTGUL\">MNC<\/strong><br \/>\n<\/b>: 07 (Movistar)<\/li>\n<li class=\"editor_editorListItem__O5oI5\" value=\"3\"><b><strong class=\"editor_editorTextBold__UTGUL\">MSIN<\/strong><br \/>\n<\/b>: 1234567890 (Subscriber&#8217;s Unique Identifier)<\/li>\n<\/ul>\n<p class=\"editor_editorParagraph__isQNM\" dir=\"ltr\">By verifying the MCC and MNC, you can confirm that the phone number belongs to a Movistar subscriber in Spain, which helps validate its authenticity.<\/p>\n<pre>{<\/pre>\n<p>&#8220;id&#8221;: &#8220;364215&#8221;,<\/p>\n<p>&#8220;term&#8221;: &#8220;34677934019&#8221;,<\/p>\n<p>&#8220;request_id&#8221;: &#8220;364215&#8221;,<\/p>\n<p>&#8220;result_code&#8221;: &#8220;101&#8221;,<\/p>\n<p>&#8220;result_type&#8221;: &#8220;Connected&#8221;,<\/p>\n<p>&#8220;result&#8221;: {<\/p>\n<p>&#8220;phone_number&#8221;: &#8220;+34677934019&#8221;,<\/p>\n<p>&#8220;number_type&#8221;: &#8220;mobile&#8221;,<\/p>\n<p>&#8220;timezone&#8221;: &#8220;Atlantic\/Canary&#8221;,<\/p>\n<p>&#8220;format&#8221;: {<\/p>\n<p>&#8220;e164&#8221;: &#8220;+34677934019&#8221;,<\/p>\n<p>&#8220;international&#8221;: &#8220;+34 677 93 40 19&#8221;,<\/p>\n<p>&#8220;national&#8221;: &#8220;677 93 40 19&#8221;,<\/p>\n<p>&#8220;rfc3966&#8221;: &#8220;tel:+34-677-93-40-19&#8221;<\/p>\n<p>},<\/p>\n<p>&#8220;is_ported&#8221;: true,<\/p>\n<p>&#8220;reachable&#8221;: &#8220;connected&#8221;,<\/p>\n<p>&#8220;processing_status&#8221;: &#8220;completed&#8221;,<\/p>\n<p>&#8220;imsi&#8221;: &#8220;214040000000000&#8221;,<\/p>\n<p>&#8220;current_network&#8221;: {<\/p>\n<p>&#8220;country_iso2&#8221;: &#8220;EN&#8221;,<\/p>\n<p>&#8220;country_prefix&#8221;: &#8220;34&#8221;,<\/p>\n<p>&#8220;country_name&#8221;: &#8220;Spain&#8221;,<\/p>\n<p>&#8220;mccmnc&#8221;: &#8220;21404&#8221;,<\/p>\n<p>&#8220;mcc&#8221;: &#8220;214&#8221;,<\/p>\n<p>&#8220;mnc&#8221;: &#8220;04&#8221;,<\/p>\n<p>&#8220;area&#8221;: &#8220;ES&#8221;,<\/p>\n<p>&#8220;network_name&#8221;: &#8220;Yoigo&#8221;.<\/p>\n<p>},<\/p>\n<p>&#8220;original_network&#8221;: {<\/p>\n<p>&#8220;country_iso2&#8221;: &#8220;EN&#8221;,<\/p>\n<p>&#8220;country_prefix&#8221;: &#8220;34&#8221;,<\/p>\n<p>&#8220;country_name&#8221;: &#8220;Spain&#8221;,<\/p>\n<p>&#8220;mccmnc&#8221;: &#8220;21401&#8221;,<\/p>\n<p>&#8220;mcc&#8221;: &#8220;214&#8221;,<\/p>\n<p>&#8220;mnc&#8221;: &#8220;01&#8221;,<\/p>\n<p>&#8220;area&#8221;: &#8220;ES&#8221;,<\/p>\n<p>&#8220;network_name&#8221;: &#8220;Vodafone&#8221;.<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h2>How to create a telephone number validator with PHP<\/h2>\n<p>To facilitate the use of the phone validator in your forms and applications, we have created a <a href=\"https:\/\/www.verificaremails.com\/kb\/utilizar-postman-para-el-api-de-verificaremails\/\">POSTMAN library<\/a> where you can download the api calls as well as code examples. In the case of our example, if we want to make a call in PHP, we must select this language within the Postman collection and the application itself will generate the PHP call to validate a phone number.<\/p>\n<p><img fetchpriority=\"high\"  decoding=\"async\" class=\"alignnone size-full wp-image-9449\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303.webp\" alt=\"validate phone number in php\" width=\"3817\" height=\"1820\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303.webp 1920w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303-300x143.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303-1024x488.webp 1024w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303-768x366.webp 768w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/06\/Captura-de-pantalla-2024-06-19-184303-1536x732.webp 1536w\" sizes=\"(max-width: 3817px) 100vw, 3817px\" \/><\/p>\n<h2>Why validate phone numbers<\/h2>\n<p>Capturing leads is expensive and will become more so every day. It is estimated that between 8-12% of the telephones captured on forms or during registration processes are erroneous. Data verification at the point of capture allows these errors to be detected and registration rates to be improved.<\/p>\n<p>Once the lead is captured, it enters a &#8220;sales funnel&#8221; for its exploitation. If the phone number is wrong, we will be allocating resources that will never get a return. Our advice is to verify all phone numbers at the point of acquisition, but if you haven&#8217;t done so, at least verify the database to get a true picture of your potential customers.<\/p>\n<h2>Conclusions<\/h2>\n<p>We have seen the different ways to <a href=\"https:\/\/www.verificaremails.com\/validar-numeros-telefono\/\">validate phone numbers<\/a>. We have seen that this service is indicated for the verification of mobile numbers during the registration process, improving the quality of the data and avoiding the capture of invalid numbers. Remember that you can apply <a href=\"https:\/\/www.verificaremails.com\/validar-numeros-telefono\/hlr-lookup\/\">HLR Lookup validation<\/a> to individual phones, massively to files with a high volume of numbers or automating the process with the number validation API.<\/p>\n<p>We recommend that you review the <a href=\"https:\/\/www.verificaremails.com\/docs\/en\/index_telefonos.html#tag\/HLR-Validation-API\">validation API documentation<\/a> for the different <a href=\"https:\/\/www.verificaremails.com\/docs\/index_telefonos.html#tag\/HLR-Validation-API\">phone<\/a> calls and if you want to have access to the validation libraries in the different programming languages. Although the API calls are Rest, it will always make it easier for you to integrate the service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article you will learn how to use the HLR Lookup API to validate phone numbers in real time. You will see how to perform individual validations, mass validations through files and how to automate the processes to create a number validator through the API. We will see several code examples, focusing on some &#8230; <a title=\"HLR Lookup API for phone number validation\" class=\"read-more\" href=\"https:\/\/www.verificaremails.com\/en\/hlr-lookup-api-for-phone-number-validation\/\" aria-label=\"Read more about HLR Lookup API for phone number validation\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[992],"tags":[],"class_list":["post-9457","post","type-post","status-publish","format-standard","hentry","category-verify-phones"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/posts\/9457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/comments?post=9457"}],"version-history":[{"count":0,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/posts\/9457\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/media?parent=9457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/categories?post=9457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/tags?post=9457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}