You can use OData functions to select, filter, expand, sort, and paginate the data returned from the Prospect CRM API. This article explains each function and includes examples to help you build effective queries.
Before using this guide, make sure you have authenticated and can connect to the API. See Get started with the OData API for setup instructions.
Use $select to choose fields
Use $select to return only the fields you need, rather than all fields on an entity. This keeps responses fast and manageable.
Syntax: $select=[Field1],[Field2]
Examples
To return the surname of every contact:
https://crm-odata-v1.prospect365.com/Contacts?$select=Surname
To returns the ID, forename, and surname of every contact:
https://crm-odata-v1.prospect365.com/Contacts?$select=ContactId,Forename,Surname
Use $expand to include related records
Use $expand to move from your base entity to related entities in the data hierarchy. This works in both directions, for example, from a contact to their company, or from a company to all its contacts. It is most similar to a JOIN in SQL.
Syntax: $expand=[Navigation Property]
Examples
To return all contacts and their associated division:
https://crm-odata-v1.prospect365.com/Contacts?$select=Surname&$expand=Division
To return all contacts with only the division name included from the expanded record:
https://crm-odata-v1.prospect365.com/Contacts?$select=Surname&$expand=Division($select=Name)
You can chain multiple functions inside an expand using ";". For example, to select fields on a contact, expand to the company, and select fields on that company:
https://crm-odata-v1.prospect365.com/Contacts?$expand=Division($select=Name;$expand=Company)
Use $filter to narrow results
Use $filter to return only the records that meet a specific condition. There are two filter formats depending on the operator you use.
Format 1: Comparison operators
Syntax: $filter=[Field] [Operator] [Value]
Operator | Description |
eq | Exactly equal to. |
ne | Not equal to. |
lt | Less than (not including). |
gt | Greater than (not including). |
le | Less than or equal to. |
ge | Greater than or equal to. |
Format 2: String operators
Syntax: $filter=[Operator]([Field],[Value])
Operator | Description |
contains | Value is contained somewhere in the field. |
not contains | Inverse of contains. |
startswith | Field starts with the value. |
not startswith | Inverse of startswith. |
endswith | Field ends with the value. |
not endswith | Inverse of endswith. |
Combine filters
You can chain filters together using and or or:
$filter=[Field] [Operator] [Value] and [Operator]([Field],[Value])
Examples:
To return every contact with the forename Johnson.
https://crm-odata-v1.prospect365.com/Contacts?$filter=Forename eq 'Johnson'
To return every active contact with a ProspectSoft email address.
https://crm-odata-v1.prospect365.com/Contacts?$filter=contains(Email,'@prospectsoft.com') and StatusFlag eq 'A'
📌 Note: For additional filter operators and expressions, see the Microsoft OData filter documentation.
Use $orderby to sort results
Use $orderby to sort the data returned by a specific field, in either ascending or descending order.
Syntax: $orderby=[Field] [asc|desc]
If you omit the direction, the default is ascending.
Examples
Return every ProspectSoft contact, ordered by the date the record was created (ascending):
https://crm-odata-v1.prospect365.com/Contacts?$filter=contains(Email,'@prospectsoft.com')&$orderby=Created
Same result, with the direction stated explicitly:
https://crm-odata-v1.prospect365.com/Contacts?$filter=contains(Email,'@prospectsoft.com')&$orderby=Created asc
Use $top and $skip to paginate results
Use $top and $skip together to paginate through large data sets. $top limits the number of records returned, and $skip tells the API how many records to skip before it starts returning results.
Syntax:
$top=[number]$skip=[number]
Examples
Return the first 50 contacts:
https://crm-odata-v1.prospect365.com/Contacts?$top=50&$skip=0
Return the next 50 contacts (records 51 to 100):
https://crm-odata-v1.prospect365.com/Contacts?$top=50&$skip=50
🤓 Tip: Paginating with $top and $skip is the recommended way to retrieve large data sets. Avoid running unfiltered queries on large entities such as Contacts.
Build a complete query
You can combine multiple functions in a single query by chaining them with &. The example below selects specific fields, filters by email domain and status, and expands to include related lead records:
https://crm-odata-v1.prospect365.com/Contacts?$select=Title,Forename,Surname,Email,StatusFlag&$filter=contains(email,'@prospectsoft.com') and StatusFlag eq 'A'&$expand=Leads($select=Description,Created,StatusFlag;$filter=StatusFlag eq 'A' and Status/DeadFlag eq 0;$expand=Status($select=Description))
📌 Note: The Prospect CRM OData service does not require a / between the entity and the parameters. Other OData services may differ.
