Querying

There are four API methods that allow you to build a customized database query:

  • List Accounts
  • List Donations
  • List Events
  • List Memberships

The instructions in this guide apply to all four of those API methods.

Pagination

Results are paginated. Each request has its own default page size, but you can specify your own page size in the request parameters:

page.pageSize=10

The limit is 200 results per page. For queries where more than 200 results are returned, you will need to send subsequent requests to retrieve the additional pages of results:

page.currentPage=2

Results can also be sorted. The sort column must be included as an output column to use it for sorting:

page.sortColumn=Last%20Name

You can choose to sort ascending (ASC) or descending (DESC):

page.sortDirection=DESC

Search Criteria

Both standard fields and custom fields can be used as search criteria.

Standard Fields

Use the field’s name to define a search criterion.

Example:

searches.search.key=First%20Name

Custom Fields

Use the field’s ID to define a search criterion.

Example:

searches.search.key=624

Search Operators

When searching, these operators are available for most paramaters and will accept most values:

  • EQUAL
  • NOT_EQUAL
  • BLANK
  • NOT_BLANK
  • LESS_THAN
  • LESS_AND_EQUAL
  • GREATER_THAN
  • GREATER_AND_EQUAL
  • CONTAIN

searches.search.searchOperator=EQUAL&searches.search.value=[whatever]

Two operators require the value to use a specific syntax:

  • IN_RANGE
  • NOT_IN_RANGE

searches.search.searchOperator=IN_RANGE&searches.search.value=("Bob","Robert","Bobby")

Output Columns

Both standard fields and custom fields can be used as output columns. Output columns function as a Name + ID pair. This is a structural requirement due to the architecture of our API. To retrieve fields as output columns, you must include parameters for both the field’s name and ID, as shown below:

Standard Fields

You must use the Standard Field’s Name to return the field as a column. You must supply the ID parameter, but its value can be left empty.

outputfields.idnamepair.id=&outputfields.idnamepair.name=Account%ID

Custom Fields

You must use the Custom Field’s ID to return a custom field as a column. Custom Field IDs can be retrieved using listCustomFields. You must supply the Name parameter, but its value can be left empty.

outputfields.idnamepair.id=51&outputfields.idnamepair.name=

Putting it all together

Let’s build a sample query using the List Accounts method. We’ll add some line breaks to improve readability:

/* The List Accounts API URL */
https://api.neoncrm.com/neonws/services/api/account/listAccounts?

/* Session ID */
&userSessionId=[session id]

/* Output Columns: Account ID, First Name, Last Name, Email */
&outputfields.idnamepair.id=&outputfields.idnamepair.name=Account%20Id
&outputfields.idnamepair.id=&outputfields.idnamepair.name=First%20Name
&outputfields.idnamepair.id=&outputfields.idnamepair.name=Last%20Name
&outputfields.idnamepair.id=&outputfields.idnamepair.name=User%20Email  

/* Search Criteria: Email = test@test.net */
&searches.search.key=Email
&searches.search.searchOperator=EQUAL
&searches.search.value=test@test.net

/* Pagination */
&page.currentPage=1
&page.pageSize=10
&page.sortColumn=Last%20Name
&page.sortDirection=ASC

This example would look like this, correctly formatted:

https://api.neoncrm.com/neonws/services/api/account/listAccounts?&userSessionId=[session id]&outputfields.idnamepair.id=&outputfields.idnamepair.name=Account%20Id&outputfields.idnamepair.id=&outputfields.idnamepair.name=First%20Name&outputfields.idnamepair.id=&outputfields.idnamepair.name=Last%20Name&outputfields.idnamepair.id=&outputfields.idnamepair.name=User%20Email&searches.search.key=Email&searches.search.searchOperator=EQUAL&searches.search.value=test@test.net&page.currentPage=1&page.pageSize=10&page.sortColumn=Last%20Name&page.sortDirection=ASC

Abstract those custom field IDs!

If you are developing an API-based application using a sandbox NeonCRM system, be aware that the IDs for Custom Fields will be different from your production system. We recommend abstracting these IDs from your requests in order to make your code more portable when moving from sandbox to production.