- style
GET /companies
Returns an array of companies
GET /companies
Modified Date Inaccuracies
The date modified field and filters may return inaccurate and miss-leading results. Date modified constitutes any update or save to a company object. Please use with caution.
Parameters
Table of allowed parameters.
_page | unsigned int | The page of the list to display. For example, 5 will display the fifth page. Each page contains 10 resources. |
---|---|---|
_limit | unsigned int | The maximum number of resources to return. Default is 10 and maximum is 50. |
_offset | unsigned int | The position in the list of resources to return from. For example, if you had 20 resources and requested an offset of 10. Resources 10 to 19 would be returned. Offset cannot be used in conjunction with _page . |
_fields | partial string | Allows you to specify optional fields and linked objects to include in the response. |
_search | string | Allows you to search for a company (searches website and name) |
Filters
Companies filters can be used to easily filter through your company lists.
KEY | EXAMPLE | DESCRIPTION |
---|---|---|
date_modified_before | date_modified_before(1341281246) | Unix Timestamp. e.g 1341281246- Filter out companies that were not modified before this date. |
date_modified_after | date_modified_after(1341281246) | Unix Timestamp. e.g 1341281246- Filter out companies that were not modified after this date. |
date_created_before | date_created_before(1341281246) | Unix Timestamp. e.g 1341281246- Filter out companies that were not created before this date. |
date_created_after | date_created_after(1341281246) | Unix Timestamp. e.g 1341281246- Filter out companies that were not created after this date. |
manager_id | manager_id(124,32,43) | Array of number. e.g 13,10,15- Filter out companies that do not have a manager with supplied manager id. |
fax | fax(44445555,55554444) | Only return companies with matching fax number(s). |
phone | phone(44445555,55554444) | Only return companies with matching phone number(s). |
contact_number | contact_number(44445555,55554444) | Only return companies having a phone or fax matching one of the supplied phone numbers. |
default_affiliation | default_affiliation(12,32,56) | Only return companies with given default affiliation id(s). |
postal_address | postal_address(12,43,54) | Only return companies with given postal addresses. |
id | id(1,2,3) | Only return companies with given id(s) |
standing | standing(inactive) | Only return companies with given standing(s) |
status | status(12,34) | Only return companies with given company status id(s) |
max_id | max_id(12) | Only return companies with id less or equal to max_id |
min_id | min_id(342) | Only return companies with id greater or equal to min_id |
NEW order_by_asc(<type>), order_by_desc(<type>)
| _filters=order_by_desc(id) | Accepts: id, date_created, date_modified, date_last_interacted name, standing and status |
NEW <field_name>_greater_than(<value>), <field_name>_less_than(<value>), <field_name>_greater_than_or_equal(<value>), <field_name>_less_than_or_equal(<value>)
| _filters=id_greater_than(5) | Available fields: id |
NOTE: fax, phone and contact_number filters ignore whitespace.
Using the _not
suffix (e.g, id_not
) on standard in filters will return results not in.
The following sample will return companies created before Tue, 03 Jul 2012 02:07:26 GMT< that have a manager with an id 10, 11 or 100.
GET /companies?_filters=date_created_before(1341281246),manager_id(10,11,100)
Handling the response
Below is a table of available response fields and objects that are returned within the response object of the returned object. The optional fields and objects can be requested in the _fields
parameter; see included examples. Underlined values are default.
id | unsigned int | |
---|---|---|
name | string | |
website | string | |
standing | string | |
status | unsigned int or object | |
phone | string | |
fax | string | |
date_created | unsigned int | |
date_modified | unsigned int | |
comments | string | |
contact | unsigned int or object |
Fields that can be object indicate the field can be requested as a resource. For example.
GET /companies.json?_fields=contact
would return the contacts id. Where as,
GET /companies.json?_fields=contact()
would return the contact's object, including any optional fields or objects within the parenthesis.
Sample Response
GET /companies.json?_fields=contact(),standing&_limit=2
{ "response" : [ { "name" : "ADTOA", "contact" : { "email" : "rpepper@ihug.com.au", "firstname" : "Ronald", "id" : "1", "mobile" : "0425 239 666", "surname" : "Pepper IHUG" }, "standing" : "active", "id" : "1" }, { "name" : "Balgownie Veterinary Hospital", "contact" : { "email" : "mark@balgownievet.com.au", "firstname" : "Mark", "id" : "2", "mobile" : "", "surname" : "Allison" }, "standing" : "active", "id" : "2" } ], "meta" : { "more_info" : "/public_api/docs/status/ok", "status" : "ok", "message" : "Everything executed as expected." } }