<!DOCTYPE html>
<html>
<head>
<script src="//api.rocketreach.co/v1/api.min.js"></script>
<script>
var API_KEY = "3E7k0123456789abcdef0123456789abcdef";
//Generic function to handle failure.
var handleFailure = function () {
console.error("Error:", arguments);
}
var out = function (html, tag) {
document.getElementById("output").innerHTML += (tag ? ("<" + tag + ">" + html + "</" + tag + ">") : html)
}
//Once RocketReach has initialized, perform a search follwed by a lookup
var searchAndLookup = function (account) {
console.log(account);
//Start Search
out('Calling Search', "h2")
RocketReachAPI.search({name: "Travis Kalanick",title:"CEO",company: "Uber"}).then(function success(searchResult) {
//Print Results
for (var i = 0; searchResult && searchResult.profiles && i < searchResult.profiles.length; i++) {
out("Profile:" + i + ": [id:" + searchResult.profiles[i].id + ",name:" + searchResult.profiles[i].name + "]", "pre")
}
//Retreive the first Profile
out('Lookup First result (id:' + searchResult.profiles[0].id + ')', "h2")
RocketReachAPI.lookupProfile({
id: searchResult.profiles[0].id
}).then(function success(profiles) {
//Print Results
var contactInfo = profiles[0];
out("Image: <img width=50 height=50 src='" + contactInfo.profile_pic + "'/>\n"
+ JSON.stringify(contactInfo,null,4), "pre")
}, handleFailure);
}, handleFailure);
}
//Initialise
RocketReachAPI.DEBUG=true;
RocketReachAPI.init({
"api_key":API_KEY,
"success":searchAndLookup,
"error": handleFailure
});
</script>
</head>
<body>
<h1>RocketReach.co API</h1>
<p>Search for a person by name, company, keywords. Then lookup email and social links. info.</p>
<div id="output"></div>
</body>
</html>
#RocketReach API: Simple Example
1. In this example, you will see how to do a simple initialization.
1. Then the API will be used to search people by name & company.
1. The first result from search will used to lookup contact information.
## Methods used
- init()
- search()
- lookupProfile()