DukeAPI Luhn


The Luhn algorithm is a simple checksum formula.

Call DukeAPI from spreadsheets (Google Docs or Microsoft Office) or applications to perform the checksum.



Perform the Luhn checksum from your language of choice.

<?php
function duke_luhn($user_name,$key,$data)
{
    $hostname = 'http://deploy.dukeanalytics.com';
    $endpoint = '/api/v1.0/luhn'; 
    $curl_post_data = array("cc_num" => $data);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $hostname.$endpoint."/".$user_name."/".$key);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $curl_response = curl_exec($ch);
    curl_close($ch);
    return $curl_response;
};
print duke_luhn('try_it','db1542b66f16aba5768d8a19c27dec4facf9168a','123456789');
?>
import requests
user_name = 'try_it'
key = 'db1542b66f16aba5768d8a19c27dec4facf9168a'
card_number = "123456789"
data = {"cc_num": int(card_number)}
hostname = "http://deploy.dukeanalytics.com"
endpoint = "/api/v1.0/luhn"
resp = requests.post(hostname+endpoint+'/'+user_name+'/'+key,data=data)
print resp.text

require 'net/http'
user_name = 'try_it'
key       = 'db1542b66f16aba5768d8a19c27dec4facf9168a' 
hostname  = 'http://deploy.dukeanalytics.com'
endpoint  = '/api/v1.0/luhn'
card_num  = '123456789'
data      = {'cc_num' => card_num}
uri = URI(hostname+endpoint+'/'+user_name+'/'+key)
res = Net::HTTP.post_form(uri, data)
puts res.body
var request = require('request');
function sendRequest (callback) {
    var user_name= 'try_it';
    var key = 'db1542b66f16aba5768d8a19c27dec4facf9168a';
	var hostname = 'http://deploy.dukeanalytics.com';
	var endpoint = '/api/v1.0/luhn';
	var card_num = '123456789';
	var data = {'cc_num': card_num};
	var options = {
	    url: hostname + endpoint+'/'+user_name+'/'+key,
	    method: 'POST',
	    form: data
	};
	request(options, function (error, response, body) {
	        console.log('predict: API returned status %s: %s', response.statusCode, body);
	        console.log(JSON.parse(body));
	});
}
sendRequest();
exports.sendRequest = sendRequest;

See here for pricing details ...