Skip to main content

API Usage

All requests to the API require an active and valid MyJadu API key to be supplied to be able to interact with the system.

API Keys are provided at the discretion of Jadu Central platform webmasters and can be freely provided, without intervention, at the request of a registered web site user or by manually approving each request for an API key.

Example request using PHP

Below is a very basic example of how you might use the MyJadu API to display a list of documents contained in the Jadu Platform. First we must make a HTTP request to a valid MyJadu API endpoint to be able to fetch the resulting XML. Here we shall use PHP’s inbuilt cURL library to make the HTTP request, but have included no error checking for simplicity sake. Other languages and approaches are of course possible but are not covered within this document.

    $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://[domain]/api/documents/all.xml?
api_key=[api_key]');
curl_setopt($ch, CURLOPT_USERAGENT, 'Jadu');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

Example response handling using PHP

The $response variable used in the code example above will now contain the response to the API call. In the above case, this should now return a list of all documents within a Jadu Central instance in a structured XML response.

    <?xml version="1.0" encoding="utf-8"?>
<documents page="1" pages="1" per_page="10" total="2">
<document id="1" pages="1" visible="true">
<title>Benefit claims</title>
<date>1328623403</date>
<categories>
<category id="100001" name="Advice and benefits" />
</categories>
</document>
<document id="2" pages="5" visible="true">
<title>Bin collections</title>
<date>1328623422</date>
<categories>
<category id="100006" name="Environment and planning" />
</categories>
</document>
</documents>

We can now use the SimpleXML library built into PHP to parse the returned XML and output a list of the document titles for example within our PHP script.

    $xml = new SimpleXMLElement($response);
foreach ($xml->document as $document) {
$documentTitle = (string) $document->title;
print htmlentities($documentTitle, ENT_QUOTES, 'UTF-8') . '<br />'
}