# api get contacts with condition on field equal to certain value

**URL:** <https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [February 18, 2020, 8:03am UTC](https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841 "2020-02-18T08:03:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/aviho/32/31851_2.png) [@aviho](https://community.hubspot.com/u/aviho)\
**Post date:** [February 18, 2020, 8:03am UTC](https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841/1 "2020-02-18T08:03:44Z")

</div>

Hi, someone knows if it possible to get the last 150 contacts to via API with condition field equal to certain value and to get only a few field data?

---

<div class="post-metadata">

**Author:** ![Willson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/willson/32/84663_2.png) [@Willson](https://community.hubspot.com/u/Willson)\
**Post date:** [February 18, 2020, 9:23am UTC](https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841/2 "2020-02-18T09:23:06Z")

</div>

Hi @aviho

Your best bet if you’re only looking to get the most recent contacts; in this case the most recent 150 contacts, is to use the [Get recently updated and created contacts endpoint](https://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts).

This endpoint will allow you to fetch contacts going back 30 days but is limited to 100 per page. Therefore, we can use a `count` parameter to restrict the results to the recent 150 contacts.

We’d get a Request URL looking like this:

`https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?hapikey={{hapikey}}&count=100`

With this request, we’d then get an `offset` value to work with which would give us the next page of results, but to make this easier, we can update the `&count` parameter to be equal to 50, this way 3 requests with 2 using `offset` parameters will return the 150 for you.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![aviho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/aviho/32/31851_2.png) [@aviho](https://community.hubspot.com/u/aviho)\
**Post date:** [February 18, 2020, 9:29am UTC](https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841/3 "2020-02-18T09:29:24Z")

</div>

thanks for your reply  
But I would like to make a request to get the last  
150 but only if they have a field equal to a certain value

---

<div class="post-metadata">

**Author:** ![Willson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/willson/32/84663_2.png) [@Willson](https://community.hubspot.com/u/Willson)\
**Post date:** [February 18, 2020, 10:45am UTC](https://community.hubspot.com/t/api-get-contacts-with-condition-on-field-equal-to-certain-value/18841/4 "2020-02-18T10:45:54Z")

</div>

Hi @aviho

Have you tried using the new v3 Search, the documentation can be found here: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs-beta/crm/search)

With this, you can filter, sort and search CRM objects. If you’re looking to filter results when a property is equal to a specific value, you can use a filter such as the following:

```auto
{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "firstname",
 "operator": "EQ",
 "value": "Alice"
 }
 ]
 }
 ]
 }

```

This request is made to the following endpoint:

`POST https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey={{hapikey}}`

I hope this helps!
