Number Portability Lookup HLR HTTP API
Example code for using the Number Portability Lookup API is available for programmers using Java, Perl, PHP, and AGI.
We also have plug-and-play scripts to integrate carrier lookups into your Asterisk dialplan - no coding required!
API Details - v3.2
Introduction to the API
Our API (Application Programming Interface) is designed to make it easy to integrate our number portability lookup service into your own application, with the minimum amount of additional programming.
Connectivity to the service
You can make an HTTP GET, or HTTP POST request; the latter is recommended if you are looking up a large quantity of numbers in a single request. There is a maximum of 100 numbers per request, and a maximum of one concurrent connection per account.
Note that SS7 querying can take a while to process, so a large batch of numbers may take a while to return fully return.
Performing an HLR Lokup
In order to perform an HLR query on one or more mobile numbers, pass the following parameters:
|user||Your account username|
|pass||Your account password|
|msisdn||The number(s) to look up in E.164 format. Separate multiple numbers with commas|
|format||Response format desired. Recommended: json, or xml. Legacy: csv (less data - see note below). |
|msc||(Optional) - Pass msc=1 to request MSC data (Costs 0.2 credits extra). Defaults is no msc data if omitted.|
Note: The CSV format is the default is no 'format' parameter is passed, and is included for legacy compatibility with older clients. It provides IMSI and MSC only. A much richer set of data about the number is available using the JSON or XML formats, so these are strongly recommended for new integrations.
Numbers should be specified in the standard E.164 international format. i.e. Country Code, and National Significant Number without National prefixing if any exist. The leading '+' symbol is not required by our service.
Example: UK 07788 450 450 -> 447788450450
Example: USA 704 451 8989 -> 17044518989
Example: AUS 0449100123 -> 61449100123
If you need help for a specific country, please [ Contact us ].
Errors which could prevent your HLR lookup being run
If there is a problem that prevents our system from running your HLR lookup you'll receive one of these error strings:
|FAIL Invalid password||The username or password you supplied were not correct.|
|FAIL Insufficient credit||Your account balance is too low. please add funds.|
|No numbers specified||You did not include an msisdn parameter in your query.|
|Request too long||More than ten msisdn numbers were included in a single query|
|ERR RATE_LIMIT_EXCEEDED||You've made more than the allowed number of concurrent connections to the server|
Example XML Format Response
You'll receive a <response> block for each MSISDN queried.
Example JSON Format Response
You'll receive a JSON array containing a data block for each MSISDN queried.
Example Legacy CSV Format Response
The fields in the CSV response are: msisdn plmn,imsi,msc:
Description of data fields contained in response
GSM / Worldwide HLR Query Response fields:
|countrycode||country code of number's home country|
|countryiso||ISO 3166 country code of number's home country|
|countryname||Name of number's home country|
|errorcode||an error number if any error, otherwise 0|
|errortext||a description of the error code (otherwise "OK")|
|imsi||the international mobile subscriber id of the subscriber|
|localformat||the number as it would be written in its home country|
|mcc||the mobile country code of the home network|
|mnc||the mobile network code of the home network|
|msisdn||the mobile number to which this query pertains|
|operatorname||the name of the home network operator|
|originalmcc||the mcc of the original operator (if ported)|
|originalmnc||the mnc of the original operator (if ported)|
|originaloperatorname||the name of the original operator (if ported)|
|plmn||plmn code of home network (mcc+mnc)|
|ported||whether the number has been ported (true/false)|
|reachable||(meta) whether the number is in coverage and reachable (true/false/undetermined)|
|transactioncost||cost of this lookup in credits (eg 1.00)|
|validnumber||(meta) whether the number is a valid subscriber (true/false/undetermined)|
Notes on meta flags:
The 'reachable' flag is a convenience flag computed on our system based on whether a full reachable IMSI was returned from the HLR subsystem - indicating that a call or text should be able to reach the subscriber equipment at this moment. If an error response is received (including temporary errors such as "Absent Subscriber" - which indicates the handset is off) then reachable will show 'false'. This is a realtime status, and does not indicate that the number might not be reachable in a few hours (maybe it's turned off overnight, or for a flight). In the event that an HLR exception occurs, or the destination number is not in a full HLR zone (such as NANP numbers), then "undetermined" will be returned to indicate that the realtime reachability status of this number could not be determined with certainty.
The 'validnumber' flag is a convenience flag computed on our system to indicate whether the MSISDN is a valid number assigned to an active subscriber (as opposed to an un-assigned, or de-activated number). The "validnumber" flag will show "true" if a full IMSI (>5 digits) is returned (indicating a full realtime HLR reply), or if the remote HLR indicates a temporary error condition that could only be indicated if that subscriber were one of its own - such as, Absent Subscriber (in which case "reachable" will indicate "false" to show that the number, while it appears to belong to a subscriber, is not currently reachable for SMS). In the event that an HLR exception occurs, a security IMSI-Prefix-Only route is used, or the number is not in a full HLR zone (such as NANP numbers), then "undetermined" will be returned to indicate that it was not possible to determine with certainty that this number is assigned to an active subscriber.
Note that reachable and validnumber fields are not returned by the HLR subsystem, but calculated based on a set of conditions in the IMSI, Errorcode, and MSC responses we receive in order to make an informed decision as to the current status of the number. In the event that we cannot guarantee that status due to external factors, we will return "undetermined" for these fields. This does not indicate the query has failed or that there is any technical problem - for example NANP numbers will show undetermined due to the OCN lookup method used in the US, which does not need to perform a realtime HLR query.
Serving MSC (Mobile Switching Centre)
The MSC value is only returned if requested by passing parameter msc=1 in your request. Adding the serving MSC address prefix to your HLR request will incease the cost to 1.2 credits for that HLR query. Be aware that we will only return the prefix of the MSC (up to 5 digits) and not the full MSC address in order to reduce the possibility of clients engaging in messaging fraud, and this is not negotiable.
North American Number Lookup Response fields:
- msisdn - the number queried
- ocn - the carrier's OCN Code
- carrier - the carrier's name
- numbertype - the type of number (eg MOBILE, PCS, WIRELESS) for mobile, (LANDLINE, CLEC, RBOC) for landline
List of possible error codes
The following is a list of response codes that can be returned in the errorcode and errortext fields:
|Code||Message||Description / Possible Cause|
|0||Lookup Complete||HLR returned valid SM routing data in response to SRI query|
|1||Unknown Subscriber|| there is no directory number for the mobile subscriber (GSM 09.02)|
|5||Unidentified Subscriber|| MAP response from MSC/VLR returned a negative response (GSM 03.07)|
|6||Absent Subscriber (SM)|| Subscriber record is marked as unavailable as there was no paging response from the handset. May be switched off, in low coverage, or subject to roaming restrictions.|
|7||Unknown Equipment|| Subscriber's mobile device has not been recognised (EIR)|
|8||Roaming Not Allowed|| Subscriber is roaming on another network where roaming agreements may not be fully in place|
|9||Illegal Subscriber|| mobile station failed authentication|
|11||Teleservice Not Provisioned|| the recipient mobile station has no SMS subscription (GSM 09.02)|
|12||Illegal Equipment|| mobile station was black-listed|
|13||Call Barred|| rejected due to barring of the mobile station (see GSM 09.02, description of the Barring supplementary service, GSM 02.04 and 03.11, and description of Operator Determined Barring, GSM 02.41 and 03.15).|
|21||Facility not Supported||SMS is not provisioned in the VPLMN (GSM 09.02).|
|27||Absent Subscriber|| VLR has no IMSI record, or if the record is marked "Subscriber Data Not Confirmed by HLR" (GSM 03.07)|
|31||Subscriber Busy for MT SMS|| rejected because of congestion encountered at the remote MSC|
|32||SM Delivery Failure|| SM Delivery Failure has occurred|
|33||Message Waiting List Full|| rejected because the mobile station is out of storage|
|34||Partner System Failure|| the network partner encountered an error performing this operation|
|35||Data Missing or Unroutable|| no routing exists to reach this prefix at the current time|
|36||Lookup Failure|| network or protocol failure, or invalid numbering plan prefix|
|38||Rejected|| hlr subsysem rejected number - non mobile or unsupported carrier|
Checking your account balance
To query the balance of your account via the API pass the following parameters:
|user||Your account username|
|pass||Your account password|
The response will give your remaining account balance as the number of lookups that can be performed before your account is depleted.
HTTP/1.1 200 OK
Multiple Simultaneous Connections
By default your account allows a maximum of 5 simultaneous HTTP connections to our API from the same user at the same time. Any additional connections will be rejected with ERR RATE_LIMIT_EXCEEDED.
We recommend that if you have a high volume of traffic you send two or more queries (up to ten) per HTTP call by separating MSISDN numbers by commas. This increases the efficiency of the traffic as you are not making a socket connection and sending HTTP headers for every individual number, but spreading that overhead across multiple lookups.
In the event that you have a high volume of traffic and five threads is not sufficient please contact your account manager.
For Further Assistance
For further assistance with the API, please [ Contact us ]
For an instant-setup account to try our API - [ click here ]
Usage of this API implies agreement with our terms and conditions for use [ View Terms]