Need help? Looking for tips and tricks?

This knowledge base contains loads of useful advice and answers to common questions.

If you're still stuck you can always submit a support request and we'll get back to you ASAP.

API v2.x Developers' Guide

Support -

Overview

Citizen Space API v2.x is an extension of Citizen Space API v1.0. Therefore, it is recommended that you read the Developers' Guide for API v1.0. API v2.3 adds json_search_results and json_consultation_details methods, both of which return JSON structures.

References to "1.0" in the Developers' Guide for API v1.0 can now be replaced with "2.3". For example, the Developers' Guide for API v1.0 states that methods should be called via HTTP GET requests, using the format url_of_citizen_space_instance/api/1.0/methodname?arguments but they can now be called using the format url_of_citizen_space_instance/api/2.3/methodname?arguments.

You can talk to the API using any server-side or client-side language that supports HTTP requests.

Basic GET request

To call json_search_results via an HTTP GET request, use the following format:

http://www.citizenspace.com/demo/api/2.3/json_search_results?arguments

This returns a JSON structure as detailed in the API Reference.

Client side API calls

Due to the same origin policy you need to use JSONP for client-side API calls. We use the same callback name as the JQuery default.

$.getJSON(
"http://www.citizenspace.com/demo/api/2.3/json_search_results?callback=?",
{
'tx': 'green',
'st': 'open'
},
function(data, textStatus, jqXHR) {
// Handle returned data
}
);

This should return exactly the same data as hitting the following URL in your browser:

http://www.citizenspace.com/demo/api/2.3/json_search_results?callback=?&tx=green&st=open

Note that the function above is only a simple demonstration; in a production site you'd probably want to check the response's status code to make sure the Citizen Space site is accessible and responding to API calls.
 

For an example use case, please refer to "Embedding a consultation finder in your site" in the API Version 1.0 Developers' Guide.

The example HTML below shows a list of all titles including the substring "green":

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<ul id="consultation_list">
</ul>

<script>
$.getJSON("http://www.citizenspace.com/demo/api/2.3/json_search_results?callback=?",
{
'tx': 'green'
},
function(data) {
$.each(data, function(i, item) {
$('#consultation_list').append("<li>" + item.title + "</li>");

})
});
</script></body>
</html>
Powered by Zendesk