Reading from the API
Use GET methods on the Capsule API to retrieve details about records on your account. For example the API method for retrieving all the people & organisations on your Capsule account:
GET /api/party
Use the following curl to retrieve the party records listed from your account (remember to replace the API token and change sample in the URL to match your account):
curl -u d4a581cceff06c03a47015643661ee75:x https://sample.capsulecrm.com/api/party
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parties>
<person>
<...>...</...>
</person>
<organisation>
<...>...</...>
</organisation>
</parties>
Unless you specify otherwise GET methods will return results in XML format; however it’s good practise to specify Accept:application/xml in the header of your request. In curl is the -H option to add a request header e.g -H "Accept:application/xml"
curl -u d4a581cceff06c03a47015643661ee75:x -H "Accept:application/xml" https://sample.capsulecrm.com/api/party
Response
In the examples the responses from the API have been pretty printed to be easier to read - the API will return the results with unnecessary new lines and white space removed.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<parties>
<person>
<id>100</id>
<firstName>Eric</firstName>
<lastName>Schmidt</lastName>
<createdOn>2011-09-14T15:22:01Z</createdOn>
<updatedOn>2011-12-14T10:45:46Z</updatedOn>
</person>
<person>
<id>101</id>
<firstName>Larry </firstName>
<lastName>Page</lastName>
<createdOn>2011-09-14T15:22:01Z</createdOn>
<updatedOn>2011-11-15T10:50:48Z</updatedOn>
</person>
<organisation>
<id>50</id>
<name>Google Inc</name>
<createdOn>2011-09-14T15:22:01Z</createdOn>
<updatedOn>2011-12-14T10:45:46Z</updatedOn>
</organisation>
</parties>
As well as XML you can also retrieve data in JSON format. To use JSON in your GET requests specify Accept:application/json in the header.
curl -u d4a581cceff06c03a47015643661ee75:x -H "Accept:application/json" https://sample.capsulecrm.com/api/party
{
"parties": {
"person": [
{
"id": "100",
"firstName": "Eric",
"lastName": "Schmidt",
"createdOn": "2011-09-14T15:22:01Z",
"updatedOn": "2011-12-14T10:45:46Z"
},
{
"id": "101",
"firstName": "Larry ",
"lastName": "Page",
"createdOn": "2011-09-14T15:22:01Z",
"updatedOn": "2011-11-15T10:50:48Z"
}
],
"organisation": {
"id": "50",
"name": "Google Inc",
"createdOn": "2011-09-14T15:22:01Z",
"updatedOn": "2011-12-14T10:45:46Z"
}
}
}
Next Step Writing to the API
