Introduction
Searched for some examples on the White Pages Json API, and haven't found much. If you look at their documentation, http://developer.whitepages.com/docs, you'll notice a pretty good explanation of everything, but it does take a little time to parse everything out. I turned to the YQL Console in order to test and figure out how everything was broken down and developed a script to have a basic search of People by Name and Zip Code, and a Reverse Phone Number Search in order to tell what number belongs to who.
For further information, I am using YQL, (documentation is found at: http://developer.yahoo.com/yql/), and the White Pages API, (documentation is found at: http://developer.whitepages.com).
Using the Code
If you download the source, it will not work until you have signed up with Whitepages.com first in order to get an API Key. Once you have this, simply plug it into the 2 javascript files located under the Scripts/whitepages folder at the top where it says:
var apiKey = 'YOUR API KEY';
The scripts themselves are pretty lengthy, so I'll keep the summary fairly short...
function findPerson(name,zip) {
$('#data').empty();
var apiKey = 'YOUR API KEY';
var query = 'select * from json where url=" + name +
';zip=' + zip + ';api_key=' + apiKey + ';outputtype=JSON"'
$.getJSON(
"http:
"&format=json&callback=?",
function(data) {
$.each(data.query.results,
function(index, item) {
if (item.result.code == 'Found Data') {
if (item.meta.recordrange.totalavailable == 1) {
}
}
else{
}
else{
}}
function findNumber(number) {
$('#phoneData').empty();
var apiKey = 'YOUR API KEY';
var query = 'select * from json where url=" + number + ';api_key=' +
apiKey + ';outputtype=JSON"';
$.getJSON(
"http:
encodeURIComponent(query) + "&format=json&callback=?",
function(data) {
$.each(data.query.results,
function(index, item) {
if (item.result.code == 'Found Data') {
}
else{
}}
Pretty much it.
View sample for further details.
A live example is located at http://www.joshuablackstone.net/WhitePagesAPI. (Forgive the Godaddy ads... lol).
Finally, I realize that there may be better ways to do this, and I am NOT an expert in JavaScript, so if you have a way to make this even better, then feel free to comment.
History
- 16th March, 2010: Initial post