Can I search using the API for contacts based on custom fields

I can’t seem to find a way or any reference to searching on custom fields from the API. When I do, it seems to ignore it and return all records. I did use the name of the custom field for the API that IS gives you and added the preceding underscore, but no luck. It seems like this should be possible, am I missing something or is it actually not possible?

The question is how are you doing the search? Can you share your code example?

As you said you should be able to do this: “_CustomField” => “ABC”.
Old iSDK example: $infusionsoft->dsQuery(‘Contact’, 1000, 0, array(‘_Term’ => 456), array(‘Id’, ‘FirstName’));

The Custom Field Name needs to match exactly the one stored in Infusionsoft.

Thanks for the reply.

So I’m using Python, and using Requests to do the query:
This works exactly as expected:

IS = requests.get(
    "https://api.infusionsoft.com/crm/rest/v1/contacts",
    params={'family_name': 'bond', 'access_token' : IS_token}
 )

So I know the token and everything else is right. The problem is with this:

IS = requests.get(
    "https://api.infusionsoft.com/crm/rest/v1/contacts",
    params={'_OrderNumber1': '57148', 'access_token' : IS_token}
)

It returns all records.

If I query https://api.infusionsoft.com/crm/rest/v1/contacts/model it does list the custom fields, but only the keys. I notice these are all under the JSON subarray of custom_fields. I’m starting to think I’m asking the wrong question, as I know that ‘email’ is also under the subarray email_addresses, and I can’t figure out how to query on that field either. Any insight on how I would access those?
Thanks

Not sure if you’re using REST what it would be but I believe the SDK includes a query by field.

I personally stay away from using REST because it is incomplete.

Looking at the REST documentation it is very limited to what it can search on:
https://developer.infusionsoft.com/docs/rest/#!/Contact/listContactsUsingGET

You will have to go through the XML-RPC route to query by the Custom Field.
This is the API function you would need, and the table is “Contact”.
https://developer.infusionsoft.com/docs/xml-rpc/#data-query-a-data-table

There is a Python example there, so your Query Parameters would work.

Thanks for the tips. This was my first attempt and I had no idea there was an SDK, so I’m gonna give that a go, as it seems much cleaner. Cheers

Has there been any further attempts to add support for this via the ReST API calls? I’d love to be able to make a ReST call for a contact via a custom field.

Seems like I may have received my answer from this other question here:

tl;dr Due to system constraints, filtering contact list by a custom field isn’t possible with the ReST API calls.

Hi @John_Flynn, @John_Borelli and @Daniel_Strood.

Custom field filtering is now available in REST v2 for the following resources:

  • Contacts

  • Companies

  • Orders

  • Affiliates

For these supported resources, custom fields can be filtered just like any other field using the filter parameter.

Some highlights:

  • Filter custom fields by their field name (case-insensitive, as returned by GET /v2/{resource}/model).

  • Support varies by field type:

    • Text-like fields (text, name, email, phone, website): == (with an optional trailing wildcard *)

    • Choice fields (dropdown, radio, yes/no, user, state): ==

    • Numeric fields: ==, >, <, >=, <=

    • Date fields: ==, >, <, >=, <= using full ISO 8601 format

    • Multi-select fields: == matches records containing the specified option

If a standard field and a custom field have the same name, the standard field takes precedence.

Please note that filtering on non-indexed custom fields is supported but may result in slower query performance.

For complete details and examples, please refer to the API documentation.

Support for the remaining resources that currently support custom field filtering in XML-RPC will also be added to REST v2 soon.

Replying back to my reply that I made in May 2019 (7 years ago).

REST v2 is mostly comparable to XML-RPC, and is far better than the poor implementation that was done in REST v1.

Given that Keap announced that XML-RPC will be sunset at the end of December 2026. So you do have migrate across and have to say goodbye to XML-RPC.

Thank you for tagging me in this reply! It would be great if some sort of mass email went out to all the registered devs.