closeio / closeio-api

Python API Client for Close
http://developer.close.com/
MIT License
65 stars 47 forks source link

Documentation: sample-usage-of-api-client #87

Closed csoare7 closed 7 years ago

csoare7 commented 7 years ago
lead_results = api.get('lead', params={
    '_limit': 10,
    '_fields': 'id,display_name,status_label',
    'query': 'custom.my_custom_field:"some_value" status:"Potential" sort:updated'
})

should be changed to:

lead_results = api.get('lead', params={
    '_limit': 10,
    '_fields': 'id,display_name,status_label',
    'custom.my_custom_field':'some_value',
    'status': 'Potential',
    'sort':'updated'
})

Trying to run the following query will not return a filtered result:

api.get('activity/status_change/opportunity', {'_limit':100, '_fields': 'opportunity_id,lead_id', 'query':'opportunity_id:"some_id"'})
philfreo commented 7 years ago

The change you mentioned is incorrect. On the Lead List/Search endpoint, there is a special GET parameter called query that takes a Close.io Search Query such as custom.my_custom_field:"some_value" status:"Potential" sort:updated. This special query syntax allows much more granular searching/filtering (including boolean operators like OR) than typical GET query string parameters.

(See also our API docs: https://developer.close.io/#leads)

The reason your activity/status_change/opportunity query didn't do what you want is that the API doesn't support the same filters on each endpoint. As you can see on https://developer.close.io/#activities-list-or-filter-all-opportunitystatuschange-activities, there is no query parameter.

Let us know if you have any more questions/issues