Account  |   Register  |   Pricing  |   Asterisk  |   HTTP API   |   ENUM   |   Code  |   Batch Client   |   Networks  |   Status  |   About  |   Contact

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.

    We also have an ENUM/NAPTR (DNS based) API that may be better suited depending on your integration needs.

Connectivity to the service

    Connectivity to the API is provided by via HTTP(s) GET or POST to one of the following URLs:

    http://api.comcetera.com/npl
    https://secure.comcetera.com/npl (Recommended)
    
    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:

    userYour account username
    passYour account password
    msisdnThe number(s) to look up in E.164 format. Separate multiple numbers with commas
    formatResponse 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.

    Example Request:

    http://api.comcetera.com/npl?user=bob&pass=123&msisdn=447788450450,447810701702&msc=1&format=json

Number Formatting

    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 passwordThe username or password you supplied were not correct.
      FAIL Insufficient creditYour account balance is too low. please add funds.
      No numbers specifiedYou did not include an msisdn parameter in your query.
      Request too longMore than ten msisdn numbers were included in a single query
      ERR RATE_LIMIT_EXCEEDEDYou've made more than the allowed number of concurrent connections to the server

Example Responses

    Example XML Format Response

      You'll receive a <response> block for each MSISDN queried.

      <responsedata>
      	<response>
      		<countrycode>44</countrycode>
      		<countryiso>GB</countryiso>
      		<countryname>United Kingdom</countryname>
      		<errorcode>0</errorcode>
      		<errogtext>OK</errogtext>
      		<imsi>234158341040126</imsi>
      		<localformat>07788 450450</localformat>
      		<mcc>234</mcc>
      		<mnc>15</mnc>
      		<msc>44778</msc>
      		<msisdn>447788450450</msisdn>
      		<operatorname>Vodafone</operatorname>
      		<originalmcc>234</originalmcc>
      		<originalmnc>15</originalmnc>
      		<originaloperatorname>Vodafone</originaloperatorname>
      		<plmn>23415</plmn>
      		<pogted>false</pogted>
      		<reachable>true</reachable>
      		<transactioncost>1.20</transactioncost>
      		<validnumber>true</validnumber>
      	</response>
      </responsedata>
      

    Example JSON Format Response

      You'll receive a JSON array containing a data block for each MSISDN queried.

      [
      	{
      		"countrycode":"44",
      		"countryiso":"GB",
      		"countryname":"United Kingdom",
      		"errorcode":"0",
      		"errortext":"OK",
      		"imsi":"234158341040126",
      		"localformat":"07788 450450",
      		"mcc":"234",
      		"mnc":"15",
      		"msc":"44778",
      		"msisdn":"447788450450",
      		"operatorname":"Vodafone",
      		"originalmcc":"234",
      		"originalmnc":"15",
      		"originaloperatorname":"Vodafone",
      		"plmn":"23415",
      		"ported":"false",
      		"reachable":"true",
      		"transactioncost":"1.20",
      		"validnumber":"true"
      	}
      ]
      

    Example Legacy CSV Format Response

      The fields in the CSV response are: msisdn plmn,imsi,msc:

      QUERYOK
      447788450450 23415,234158341040126,44778
      ENDBATCH
      

Description of data fields contained in response

    GSM / Worldwide HLR Query Response fields:

    countrycodecountry code of number's home country
    countryisoISO 3166 country code of number's home country
    countrynameName of number's home country
    errorcodean error number if any error, otherwise 0
    errortexta description of the error code (otherwise "OK")
    imsithe international mobile subscriber id of the subscriber
    localformatthe number as it would be written in its home country
    mccthe mobile country code of the home network
    mncthe mobile network code of the home network
    msisdnthe mobile number to which this query pertains
    operatornamethe name of the home network operator
    originalmccthe mcc of the original operator (if ported)
    originalmncthe mnc of the original operator (if ported)
    originaloperatornamethe name of the original operator (if ported)
    plmnplmn code of home network (mcc+mnc)
    portedwhether the number has been ported (true/false)
    reachable(meta) whether the number is in coverage and reachable (true/false/undetermined)
    transactioncostcost 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:

      CodeMessageDescription / Possible Cause
      0Lookup CompleteHLR returned valid SM routing data in response to SRI query
      1Unknown Subscriber there is no directory number for the mobile subscriber (GSM 09.02)
      5Unidentified Subscriber MAP response from MSC/VLR returned a negative response (GSM 03.07)
      6Absent Subscriber (SM) IMSI record is marked as detached (GSM 09.02), or MS is subject to roaming restrictions (GSM 09.02)
      9Illegal Subscriber mobile station failed authentication
      11Teleservice Not Provisioned the recipient mobile station has no SMS subscription (GSM 09.02)
      12Illegal Equipment mobile station was black-listed
      13Call 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).
      21Facility not SupportedSMS is not provisioned in the VPLMN (GSM 09.02).
      27Absent Subscriber VLR has no IMSI record, or if the record is marked "Subscriber Data Not Confirmed by HLR" (GSM 03.07)
      31Subscriber Busy for MT SMS rejected because of congestion encountered at the remote MSC
      33Message Waiting List Full rejected because the mobile station is out of storage
      34Partner System Failure the network partner encountered an error performing this operation
      35Unroutable Prefix no routing exists to reach this prefix at the current time
      36Lookup Failure network or protocol failure, or invalid numbering plan prefix
      38Rejected 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:

    userYour account username
    passYour account password
    querybalance

    Example Request:

    http://api.comcetera.com/npl?user=bob&pass=123&query=balance

    The response will give your remaining account balance as the number of lookups that can be performed before your account is depleted.

    Example Response

    HTTP/1.1 200 OK
    
    45999564
    

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]

 
© 2016 Comcetera Ltd. NumberPortabilityLookup.com is a product of Comcetera™ Ltd
Comcetera Ltd is Registered in England, Company 6058188 at Unit 13 Freeland Business Park, Poole BH16 6FH.