API
Listcleaner API Documentation
Our Email list cleaning API is easy to use and integrates within any software language.
Here you can find our email list cleaning API documentation, with ready made Ruby on Rails examples.
Getting started
Click here to go to your dashboard.
Every request to our List Cleaning API requires these header parameters:
X-User-Email string
X-Api-Key string
Depending on the API call other query parameters are:
uid string This uid is the identifier of an uploaded data file.
file string($binary) The comma separated CSV file to be uploaded
mapping string The column name of your CSV file containing the email adresses
reference string Reference for your datafile
export_type string Choose options: all, ok, bad, for the requested dataset download.
Every response from our List Cleaning API come with a response code
200 Success
401 Unauthorized (check your username and API key)
400 Missing UID or other request error (check if the UID is in the request)
404 File not found (File not found or not ready for download)
404 File not found (File not found or not ready for download)
Listcleaner API request examples
Listcleaner API - Ruby examples
Ruby
/get_credits
Retrieve the amount of available credits
Request:
require 'net/http'
require 'json'
uri = URI('https://api.listcleaner.net/get_credits')
req = Net::HTTP::Get.new(uri)
req['accept'] = 'application/json'
req['X-User-Email'] = 'username@domain.com'
req['X-Api-Key'] = 'YOUR_API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(req)
end
if res.is_a?(Net::HTTPSuccess)
puts JSON.parse(res.body) # Output user credits
else
puts "Error: #{res.code}"
end
Response (code 200):
{
"credits": 0
}
Ruby
/upload_list
Upload your email data file to be cleaned
Request:
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("https://api.listcleaner.net/upload_list")
request = Net::HTTP::Post.new(uri)
request["accept"] = "application/json"
request["X-User-Email"] = "username@domain.com"
request["X-Api-Key"] = "YOUR_API_KEY"
# Prepare the form data
form_data = [['file', File.open('YOUR_FILENAME.csv')],
['mapping', 'YOUR_MAPPING_COLUMN'],
['reference', 'YOUR_REFERENCE']]
request.set_form form_data, Multipart::Post::Boundary
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.is_a?(Net::HTTPSuccess)
puts JSON.parse(response.body) # Output the response
else
puts "Error: #{response.code}"
end
Response (code 200):
{
"status": "File uploaded successfully",
"uid": "d53dec-bac2b5-34dfd1",
"records_total": 28391
}
Ruby
/show_lists
Have a look at all your lists
?uid is optional and will only show that specific list.
Request:
require 'net/http'
require 'uri'
require 'json'
# Optional uid parameter
uid = "abc123-def456-ghi789"
uri = URI.parse("https://api.listcleaner.net/show_lists?uid=#{uid}")
request = Net::HTTP::Get.new(uri)
request["accept"] = "application/json"
request["X-User-Email"] = "username@domain.com"
request["X-Api-Key"] = "YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.is_a?(Net::HTTPSuccess)
puts JSON.parse(response.body) # Output the response
else
puts "Error: #{response.code}"
end
Response (code 200):
{
"lists": [
{
"uid": "abc123-def456-ghi789",
"created": "2024-01-01 00:00:01",
"filename_original": "dummy.csv",
"reference": "Dummy File Upload",
"mapping": "emailaddress",
"records_total": 436,
"records_processed": "436",
"records_ok": "405",
"records_bad": "31",
"records_bad_breakdown": "{\"catch_all\": 2, \"blacklisted_email\": 1, \"spamtrap\": 1, \"account_inactive\": 4, \"syntax_error\": 1, \"mx_server_offline\": 1, \"invalid_mx\": 3, \"disposable_domain\": 16, \"mx_server_error\": 2}",
"paid": "paid",
"current_step": "done",
"current_status": "done",
"last_status_update": "2024-01-01 00:01:02"
}
]
}
Ruby
/download_list
Download your cleaned lists, when its current_status is "done".
Options:
all -> Export of all the data
ok -> Export of the clean data
bad -> Export of the bad data
The statuses can be found in the "reason" column.
(We use "abc123-def456-ghi789" as example uid.)
Request:
require 'net/http'
require 'uri'
require 'fileutils'
# Parameters
uid = "abc123-def456-ghi789"
export_type = "all"
uri = URI.parse("https://api.listcleaner.net/download_list?uid=#{uid}&export_type=#{export_type}")
request = Net::HTTP::Get.new(uri)
request["accept"] = "*/*"
request["X-User-Email"] = "username@domain.com"
request["X-Api-Key"] = "YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.is_a?(Net::HTTPSuccess)
# Save the response body to a file
File.write('downloaded_list.csv', response.body)
puts "List downloaded successfully."
else
puts "Error: #{response.code}"
end
Ruby
/delete_list
Remove your list from the panel
Request:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class DeleteList {
public static void main(String[] args) {
// Parameters
String uid = "abc123-def456-ghi789";
String urlString = "https://api.listcleaner.net/delete_list?uid=" + uid;
try {
// Create a URL object
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set the HTTP request method to POST
connection.setRequestMethod("POST");
// Set the required headers
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("X-User-Email", "username@domain.com");
connection.setRequestProperty("X-Api-Key", "YOUR_API_KEY");
// Optional: Send an empty body
connection.setDoOutput(true);
connection.getOutputStream().write("".getBytes());
// Get the response code to check if the request was successful
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 status code
// Read and display the response
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
// Close the stream
in.close();
// Output the response
System.out.println("Response: " + content.toString());
} else {
System.out.println("POST request failed. Response code: " + responseCode);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Response (code 200):
{
"status": "List removed successfully"
}