Bulk Uploads Via API
Overview
Our API can be used to upload large amounts of telephone numbers that customers have saved within a file or by entering large volumes of data in the body of the API request.
Users can use various API commands to upload, view the status, download, pause and schedule their batches. Much like they can when using the Batch Processing page on hlrlookup.com
All batches loaded via the API are downloadable via API or accessible by logging into your account and downloading from there.
Obtain a list of all your batches
Request Type: GET
Curl Example:
curl -H "Content-Type: application/json"
'https://batches.hlrlookup.com/batches/?apikey=your_api_key&secret=your_api_secret'
By running the above command you’ll see an overview of the available batches listing a unique “ID” for each batch, the filename, the number of lines in the batch and the status to identify the current situation with the batch.
Example Response:
{
"total": 2,
"offset": 0,
"limit": 10,
"batches": [
{
"id": "232",
"filename": "batch1.txt",
"numColumns": 1,
"ownerName": "1",
"type": "HLR_LOOKUP",
"batchArguments": {
"savetoshared": "on",
"inputformat": "auto",
"cache_days": 0,
},
"scheduledStart": null,
"creationDate": "2022-06-09T11:06:16.000Z",
"numItems": 12,
"numComplete": 12,
"status": "COMPLETE"
},
{
"id": "231",
"filename": "batch2.txt",
"numColumns": 1,
"ownerName": "1",
"type": "HLR_LOOKUP",
"batchArguments": {
"savetoshared": "on",
"inputformat": "auto",
"cache_days": 0,
},
"scheduledStart": null,
"creationDate": "2022-06-09T11:04:47.000Z",
"numItems": 12,
"numComplete": 12,
"status": "COMPLETE"
}
List details of specific batch
To do this you will need to know the 'ID' of the batch. Once you have this you can the 'ID' to your request.
Request Type: GET
Curl Example:
curl -H "Content-Type: application/json"
'https://batches.hlrlookup.com/batches/232?apikey=your_api_key&secret=your_api_secret'
This will return the details specific to that batch ID
Example Response:
{
"id": "232",
"filename": "batch10.txt",
"numColumns": 1,
"ownerName": "1",
"type": "HLR_LOOKUP",
"batchArguments": {
"savetoshared": "on",
"inputformat": "auto",
"cache_days": 0,
},
"scheduledStart": null,
"creationDate": "2022-06-09T11:04:47.000Z",
"numItems": 12,
"numComplete": 12,
"status": "COMPLETE"
}
Create a new batch
Before you can upload your data you need to first create the batch.
Request Type: POST
Curl Example:
curl -H "Content-Type: application/json" -X POST
'https://batches.hlrlookup.com/batches/?apikey=your_api_key&secret=your_api_secret' -d
'{"filename":"ThisIsATestBatch.txt","type":"HLR_V2"}'
Use the "filename" parameter to add your own filename.
Ensure you use "type": "HLR_V2" so your output file is formatted to include all the features of APIV2
Example Response:
{
"id": "233",
"filename": "ThisIsATestBatch.txt",
"numColumns": 0,
"ownerName": "1",
"type": "HLR_LOOKUP",
"batchArguments": null,
"scheduledStart": null,
"creationDate": "2022-06-14T14:34:21.000Z",
"numItems": 0,
"numComplete": 0,
"status": "INITIALIZING"
}
Adding optional parameters
When creating your batch you can also include any of our optional parameters.
These parameters are the same as available using the standard API.
For a list of the available parameters click HERE
To include any of these parameters when creating your batch you need to include "batchArguments" within your request.
Request Type: POST
Curl Example using all optional parameters:
curl -H "Content-Type: application/json" -X POST
'https://batches.hlrlookup.com/batches/?apikey=your_api_key&secret=your_api_secret' -d
'{"filename":"ThisIsATestBatch.txt","type":"HLR_V2", "batchArguments": {"cache_days_private": 30, "cache_days_global": 30, "save_to_cache": "YES", "output_format": "GBR", "input_format": "GBR", "get_ported_date": "YES", "get_landline_status": "YES", "usa_status": "YES"}}'
Example Response:
{
"id": "233",
"filename": "ThisIsATestBatch.txt",
"numColumns": 0,
"ownerName": "1",
"type": "HLR_V2",
"batchArguments": {
"cache_days_private": 30,
"cache_days_global": 30,
"save_to_cache": "YES",
"output_format": "GBR",
"input_format": "GBR",
"get_ported_date": "YES",
"get_landline_status": "YES",
"usa_status": "YES"
},
"scheduledStart": null,
"creationDate": "2022-07-06T15:05:13.000Z",
"numItems": 0,
"numComplete": 0,
"status": "INITIALIZING"
}
Uploading your data
Once you have created your batch you can either upload your locally stored data as a file or by adding your numbers to the body of the API request.
Loading data from a locally saved file:
To do this include the file path of your file and the batch ID you obtained when creating your batch.
Request Type: POST
Curl Example:
curl -H "Content-Type: text/csv" -X POST --data-binary @/Documents/test-files/ThisIsATestBatch.txt
'https://batches.hlrlookup.com/batches/233/source?apikey=your_api_key&secret=your_api_secret'
Note - If the numbers you wish to check are saved within your file in a column other than the first column. For example if you have your own internal reference ID in column A and your numbers in column B. Then you can tell the API which column from your file you wish to be checked by appending &column= to the end of the URL.
Numbers Stored In | Mapping Number |
Column A | 0 |
Column B | 1 |
Column C | 2 |
Column D | 3 |
Omitting &column= from your request will always result in us checking the data stored in the first column of your file.
Curl example when data is stored in column B of your file:
curl -H "Content-Type: text/csv" -X POST --data-binary @/Documents/test-files/ThisIsATestBatch.txt
'https://batches.hlrlookup.com/batches/233/source?apikey=your_api_key&secret=your_api_secret&column=1'
Example Response:
{
"success": true
}
Loading your data into the body of the API request:
To do this add your numbers into the request body and use batch ID you obtained when creating your batch.
Request Type: POST
Curl Example:
curl -H "Content-Type: application/json" -X POST -d '["19178XXXXXX","17162XXXXXX","16183XXXXXX","16014XXXXXX","1602
3XXXXXX","15756XXXXXX","17088XXXXXX","16123XXXXXX"]'
'https://batches.hlrlookup.com/batches/233/sourcejson?apikey=your_api_key&secret=your_api_secret'
Note - There is a size limit of 2MB which equates to uploads of 100,000 numbers.
Therefore you won’t be able to upload more than 100,000 numbers in one batch when using this method.
{
"success": true
}
Processing your data
Once your data is loaded you can then start the batch by issuing the Processing command as PUT request
Request Type: PUT
Curl Example:
curl -H "Content-Type: application/json" -X PUT
'https://batches.hlrlookup.com/batches/233/?apikey=your_api_key&secret=your_api_secret' -d
'{"status": "PROCESSING"}'
Example Response:
{
"success": true
}
Pausing your batch
Once your data is processing you can then pause your batch by issuing the pause command as PUT request.
Request Type: PUT
Curl Example:
curl -H "Content-Type: application/json" -X PUT
'https://batches.hlrlookup.com/batches/233/?apikey=your_api_key&secret=your_api_secret' -d
'{"status": "PAUSED"}'
Example Response:
{
"success": true
}
To restart your batch simply run the processing command as before.
Batch scheduling
You can schedule your batch to run at a later time date if required. To do this use the scheduledStart command as a PUT request
Request Type: PUT
Curl Example:
curl -H "Content-Type: application/json" -X PUT
'https://batches.hlrlookup.com/batches/233/?apikey=your_api_key&secret=your_api_secret' -d
'{"scheduledStart": "2022-07-30T15:00:00Z"}'
Example Response:
{
"success": true
}
Downloading your results
As with the data upload process, completed batches can be downloaded in 2 ways.
Either in.CSV format or JSON format. To do this use one of the following using the following GET requests:
Download as .CSV
Request Type: GET
Curl Example:
curl -H "Content-Type: text/csv"
'https://batches.hlrlookup.com/batches/233/results?apikey=your_api_key&secret=your_api_secret'
Example Response:
,error,request_parameters.telephone_number,request_parameters.cache_days_private,request_parameters.cache_days_global,request_parameters.save_to_cache,request_parameters.output_format,credits_spent,detected_telephone_number,formatted_telephone_number,telephone_number_type,live_status,original_network,original_network_details.name,original_network_details.mccmnc,original_network_details.country_name,original_network_details.country_iso3,original_network_details.area,original_network_details.country_prefix,current_network,current_network_details.name,current_network_details.mccmnc,current_network_details.country_name,current_network_details.country_iso3,current_network_details.country_prefix,is_ported,timestamp,ported_date,request_parameters.get_ported_date,landline_status,request_parameters.get_landline_status,request_parameters.usa_status
1917XXXXXXX,NONE,1917XXXXXXX,20,15,YES,,3,1917XXXXXXX,,MOBILE,LIVE,AVAILABLE,Verizon,310004,United States of America,USA,United States of America,1,AVAILABLE,T-Mobile,310260,Puerto Rico,PRI,1,YES,2022-07-28T09:47:36Z,2022-05-11T00:00:00Z,YES,,YES,YES
1716XXXXXXX,NONE,1716XXXXXXX,20,15,YES,,2,1716XXXXXXX,,MOBILE,LIVE,AVAILABLE,Verizon,310004,United States of America,USA,United States of America,1,AVAILABLE,Verizon,310004,United States of America,USA,1,NO,2022-07-28T09:47:36Z,NOT_APPLICABLE,YES,,YES,YES
1618XXXXXXX,NONE,1618XXXXXXX,20,15,YES,,2,1618XXXXXXX,,MOBILE,LIVE,AVAILABLE,Verizon,310004,United States of America,USA,United States of America,1,AVAILABLE,Verizon,310004,United States of America,USA,1,NO,2022-07-28T09:47:36Z,NOT_APPLICABLE,YES,,YES,YES
1601XXXXXXX,NONE,1601XXXXXXX,20,15,YES,,2,1601XXXXXXX,,MOBILE,LIVE,AVAILABLE,AT&T Mobility,310410,United States of America,USA,United States of America,1,AVAILABLE,AT&T Mobility,310410,United States of America,USA,1,NO,2022-07-28T09:47:37Z,NOT_APPLICABLE,YES,,YES,YES
1602XXXXXXX,NONE,1602XXXXXXX,20,15,YES,,2,1602XXXXXXX,,MOBILE,LIVE,AVAILABLE,Sprint,310120,United States of America,USA,United States of America,1,AVAILABLE,Sprint,310120,United States of America,USA,1,NO,2022-07-28T09:47:37Z,NOT_APPLICABLE,YES,,YES,YES
1575XXXXXXX,NONE,1575XXXXXXX,20,15,YES,,2,1575XXXXXXX,,MOBILE,LIVE,AVAILABLE,AT&T Mobility,310410,United States of America,USA,United States of America,1,AVAILABLE,AT&T Mobility,310410,United States of America,USA,1,NO,2022-07-28T09:47:37Z,NOT_APPLICABLE,YES,,YES,YES
1708XXXXXXX,NONE,1708XXXXXXX,20,15,YES,,2,1708XXXXXXX,,MOBILE,LIVE,AVAILABLE,T-Mobile,310260,Puerto Rico,PRI,Puerto Rico,1,AVAILABLE,T-Mobile,310260,Puerto Rico,PRI,1,NO,2022-07-28T09:47:36Z,NOT_APPLICABLE,YES,,YES,YES
1612XXXXXXX,NONE,1612XXXXXXX,20,15,YES,,2,1612XXXXXXX,,MOBILE,DEAD,AVAILABLE,Verizon,310004,United States of America,USA,United States of America,1,AVAILABLE,Verizon,310004,United States of America,USA,1,NO,2022-07-28T09:47:36Z,NOT_APPLICABLE,YES,,YES,YES
1912XXXXXXX,NONE,1912XXXXXXX,20,15,YES,,2,1912XXXXXXX,,MOBILE,LIVE,AVAILABLE,Verizon,310004,United States of America,USA,United States of America,1,AVAILABLE,Verizon,310004,United States of America,USA,1,NO,2022-07-28T09:47:37Z,NOT_APPLICABLE,YES,,YES,YES
1956XXXXXXX,NONE,1956XXXXXXX,20,15,YES,,2,1956XXXXXXX,,MOBILE,LIVE,AVAILABLE,T-Mobile,310260,Puerto Rico,PRI,Puerto Rico,1,AVAILABLE,T-Mobile,310260,Puerto Rico,PRI,1,NO,2022-07-28T09:47:36Z,NOT_APPLICABLE,YES,,YES,YES
Download in JSON format:
Request Type: GET
Curl Example:
curl -H "Content-Type: application/json"
'https://batches.hlrlookup.com/batches/233/resultsjson?apikey=your_api_key&secret=your_api_secret'
Example Response:
[
{
"error": "NONE",
"uuid": "1a07cd0d-6d62-41f5-b67a-1dfabc1cc4d5",
"request_parameters": {
"telephone_number": "19178XXXXXX",
"save_to_cache": "YES",
"input_format": "",
"output_format": "",
"cache_days_global": 0,
"cache_days_private": 0,
"get_ported_date": "NO",
"get_landline_status": "NO",
"usa_status": "YES"
},
"credits_spent": 2,
"detected_telephone_number": "19178XXXXXX",
"formatted_telephone_number": "",
"live_status": "LIVE",
"original_network": "AVAILABLE",
"original_network_details": {
"name": "Verizon",
"mccmnc": "310004",
"country_name": "United States of America",
"country_iso3": "USA",
"area": "United States of America",
"country_prefix": "1"
},
"current_network": "AVAILABLE",
"current_network_details": {
"name": "T-Mobile",
"mccmnc": "310260",
"country_name": "United States of America",
"country_iso3": "USA",
"country_prefix": "1"
},
"is_ported": "YES",
"timestamp": "2022-11-15T11:23:10Z",
"telephone_number_type": "MOBILE",
},
{
"error": "NONE",
"uuid": "9c53ee4c-adef-4b4d-a56c-f06d86fbc37c",
"request_parameters": {
"telephone_number": "17162XXXXXX",
"save_to_cache": "YES",
"input_format": "",
"output_format": "",
"cache_days_global": 0,
"cache_days_private": 0,
"get_ported_date": "NO",
"get_landline_status": "NO",
"usa_status": "YES"
},
"credits_spent": 2,
"detected_telephone_number": "17162XXXXXX",
"formatted_telephone_number": "",
"live_status": "LIVE",
"original_network": "AVAILABLE",
"original_network_details": {
"name": "Verizon",
"mccmnc": "310004",
"country_name": "United States of America",
"country_iso3": "USA",
"area": "United States of America",
"country_prefix": "1"
},
"current_network": "AVAILABLE",
"current_network_details": {
"name": "Verizon",
"mccmnc": "310004",
"country_name": "United States of America",
"country_iso3": "USA",
"country_prefix": "1"
},
"is_ported": "NO",
"timestamp": "2022-11-15T11:23:10Z",
"telephone_number_type": "MOBILE",
},
{
"error": "NONE",
"uuid": "de52a2e6-b3b7-477b-b967-10f150ac36ee",
"request_parameters": {
"telephone_number": "16183XXXXXX",
"save_to_cache": "YES",
"input_format": "",
"output_format": "",
"cache_days_global": 0,
"cache_days_private": 0,
"get_ported_date": "NO",
"get_landline_status": "NO",
"usa_status": "YES"
},
"credits_spent": 2,
"detected_telephone_number": "16183XXXXXX",
"formatted_telephone_number": "",
"live_status": "LIVE",
"original_network": "AVAILABLE",
"original_network_details": {
"name": "Verizon",
"mccmnc": "310004",
"country_name": "United States of America",
"country_iso3": "USA",
"area": "United States of America",
"country_prefix": "1"
},
"current_network": "AVAILABLE",
"current_network_details": {
"name": "Verizon",
"mccmnc": "310004",
"country_name": "United States of America",
"country_iso3": "USA",
"country_prefix": "1"
},
"is_ported": "NO",
"timestamp": "2022-11-15T11:23:10Z",
"telephone_number_type": "MOBILE",
}
]
Deleting your batch
If required you can delete you batch by using a DELETE request
Request Type: DELETE
Curl Example:
curl -H "Content-Type: application/json" -X DELETE
'https://batches.hlrlookup.com/batches/233/results?apikey=your_api_key&secret=your_api_secret'
Example Response:
{
"success": true
}
Deleted batches are non retrievable.
Please ensure you have downloaded your data before issuing the DELETE command.
Error list
The following is a list of errors you may see when trying to upload data via the API
{
"error": "Bad Request"
}
Possible reason:
Something wrong with a parameter
{
"error": "Validation failed"
}
Possible reason:
Wrong request type - For Example GET used instead of POST
Check "filename" / "type" / "HLR_V2" / "scheduledStart" are typed correctly
Check you are using the correct Content-Type
Check the format of your scheduledStart date
{
"error": "Invalid batch arguments"
}
Possible reason
1 or more of your batchArguments are wrong. For a list of the batchArguments you can use check HERE
{
"error": "Invalid apikey or secret"
}
Possible reason:
Check your KEY or SECRET
{
"status": 400,
"error": "Internal Server Error"
}
Possible Reason
There's something wrong with the formatting of your request. Check all " " and { } are entered correctly
{
"error": "Batch not found"
}
Possible reason:
Wrong batch ID used
{
"error": "Unauthorized"
}
Possible reason:
You have tried to access that does not belong to you
Check secret= and apikey= are typed correctly
{
"status": 500,
"error": "Internal Server Error",
"errorId": "xxxxxxxxxx"
}
Possible reason:
You have tried to upload data to a batch that already has data loaded to it.