API

The Lead Zeppelin API allows you access to your lead data from your website or application. Authentication and currently available methods are described below, with examples given in PHP. Responses can be returned as JSON or XML.

Authentication

Connecting and authentication require your Lead Zeppelin username, password and API key. The following example shows a basic method that can be used to test your credentials as well as a base for all other API calls.

PHP Code Sample

<?php
$username = "{username}";
$password = "{password}";
$data     = "api_key={api_key}";
$url      = "https://www.leadzep.com/api/test";
$curl     = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);

$result   = curl_exec($curl);
curl_close($curl);

print $result;
?>

C# .NET Code Sample

string api_key  = "api_key={api_key}";
string username = "{username}";
string password = "{password}";
string auth     = "";
string data     = "&api_key=" + api_key;
Uri wuri        = new Uri("https://www.leadzep.com/api/test");

auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));
HttpWebRequest wrequest = (HttpWebRequest)WebRequest.Create(wuri);

wrequest.Headers.Add("Authorization", auth);

wrequest.Method            = "POST";
wrequest.ContentType       = "application/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter(wrequest.GetRequestStream());

requestWriter.Write(data);
requestWriter.Close();

WebResponse requestresponse = wrequest.GetResponse();
Stream dataStream           = requestresponse.GetResponseStream();
StreamReader reader         = new StreamReader(dataStream);
string responseFromServer   = reader.ReadToEnd();

requestresponse.Close();
dataStream.Close();
reader.Close();

return responseFromServer;

Be sure to replace values in curly brackets {} with your credentials.

A successful XML response will return:

<xml>
	<status>success</status>
</xml>

or formatted as JSON:

{
	"status" : "success"
}

Invalid API requests will be returned with an error status along with a contextual message. For example:

{
	"status"  : "error",
	"message" : "No match was found for the provided API key."
}

Response Format

Responses are returned as XML by default. To change the format, simply append /format/{format} to any request URL. So to return JSON in the first example, the request would be sent as https://www.leadzep.com/api/test/format/json

Methods

A description of currently available methods

Leads » Get All

Use to retrieve all lead data (returns both “contacts” & “leads”).

URL
https://www.leadzep.com/api/leads/format/{format}
Required POST data
api_key

Leads » Get Single

Use to retrieve data associated to a single contact or lead.

URL
https://www.leadzep.com/api/leads/id/{id}/format/{format}
Required POST data
api_key

Leads » Insert

Use to add a lead to your account. Append lead data (as defined in the web-to-lead documentation) to the $data variable passed via POST. For example:

PHP Code Sample

<?php
$data  = "api_key={api_key}";
$data .= "&lead[firstname]=Joe";
$data .= "&lead[lastname]=User";
$data .= "&lead[company]=ACME Blimp Supply";
$data .= "&lead[title]=Pilot";
?>

C# .NET Code Sample

data  = "api_key={api_key}";
data += "&lead[firstname]=Joe";
data += "&lead[lastname]=User";
data += "&lead[company]=ACME Blimp Supply";
data += "&lead[title]=Pilot";
URL
https://www.leadzep.com/api/leads/add/1/format/{format}
Required POST data
api_key, lead[]