# API getList()

**URL:** <https://forum.mautic.org/t/api-getlist/1746>\
**Category:** Product Support\
**Created:** [April 14, 2015, 6:38pm UTC](https://forum.mautic.org/t/api-getlist/1746 "2015-04-14T18:38:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![abenavides](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@abenavides](https://forum.mautic.org/u/abenavides)\
**Post date:** [April 14, 2015, 6:38pm UTC](https://forum.mautic.org/t/api-getlist/1746/1 "2015-04-14T18:38:30Z")

</div>

Hi. I’m connecting to Mautic via API with OAuth2.  
  
  
  
If I use $leadApi-\>getList() all leads are retrieved. I want to filter them by field alias. For example, only retrieve leads were company=‘Company’.  
  
  
  
Is this the function of the parameter $filter? If it is, what is the format for the value?  
  
  
  
Thanks!

---

<div class="post-metadata">

**Author:** ![abenavides](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@abenavides](https://forum.mautic.org/u/abenavides)\
**Post date:** [April 14, 2015, 6:38pm UTC](https://forum.mautic.org/t/api-getlist/1746/2 "2015-04-14T18:38:30Z")

</div>

Hi. I’m connecting to Mautic via API with OAuth2.

If I use $leadApi-\>getList() all leads are retrieved. I want to filter them by field alias. For example, only retrieve leads were company=‘Company’.

Is this the function of the parameter $filter? If it is, what is the format for the value?

Thanks!

---

<div class="post-metadata">

**Author:** ![gmillard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gmillard/32/5_2.png) [@gmillard](https://forum.mautic.org/u/gmillard)\
**Post date:** [April 14, 2015, 8:44pm UTC](https://forum.mautic.org/t/api-getlist/1746/3 "2015-04-14T20:44:14Z")

</div>

Hi Alvin,

The filter should support Mautic search commands and there happens to be one for company if that is what you are wanting to search by. For example “company:Company”. That can work for “name:”, “email:”, “list:”, and “owner:” as well if you want to search specifically those fields. I’m afraid other custom fields are currently not queryable but please create a feature request so we can see about getting it added!

Thanks,  
Alan

---

<div class="post-metadata">

**Author:** ![abenavides](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@abenavides](https://forum.mautic.org/u/abenavides)\
**Post date:** [April 16, 2015, 11:53am UTC](https://forum.mautic.org/t/api-getlist/1746/4 "2015-04-16T11:53:37Z")

</div>

Hi.

If I run search command "email:email@domain.com" in Mautic interface I can filter the lead I want. But if I use it with API connection I’m still retrieving all leads

```auto
$filter = 'email:email@domain.com';
$leads = $leadApi->getList($filter);
print_r($leads);
```

Is this the correct format?

Thanks

---

<div class="post-metadata">

**Author:** ![abenavides](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@abenavides](https://forum.mautic.org/u/abenavides)\
**Post date:** [April 19, 2015, 9:18pm UTC](https://forum.mautic.org/t/api-getlist/1746/5 "2015-04-19T21:18:16Z")

</div>

Hi.

I tested the other parameters and they are working as expected ($start, $limit, $orderBy, $orderByDir). I’m able to limit and order search results.

What I still can’t do is to filter them based on $filter = ‘company:Company’.

Thanks

---

<div class="post-metadata">

**Author:** ![gmillard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gmillard/32/5_2.png) [@gmillard](https://forum.mautic.org/u/gmillard)\
**Post date:** [April 20, 2015, 1:03pm UTC](https://forum.mautic.org/t/api-getlist/1746/6 "2015-04-20T13:03:40Z")

</div>

Hey Alvin,

I apologize. There was a pending PR on the api library that changed the filter parameter (the old api library code used ‘filter’ when Mautic recognized ‘search’). [https://github.com/mautic/api-library](https://github.com/mautic/api-library) So we just merged that PR. You may have to change your code a bit as we converted it to use PSR-4 as we are about to submit it to Packagist. Run `composer update` then use `include __DIR__. '/vendor/autoload.php'; ` (if your project is not already using Composer).

Thanks!  
Alan

---

<div class="post-metadata">

**Author:** ![abenavides](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@abenavides](https://forum.mautic.org/u/abenavides)\
**Post date:** [April 20, 2015, 4:42pm UTC](https://forum.mautic.org/t/api-getlist/1746/7 "2015-04-20T16:42:02Z")

</div>

Is working now… Thanks!

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [February 2, 2020, 11:00pm UTC](https://forum.mautic.org/t/api-getlist/1746/8 "2020-02-02T23:00:22Z")

</div>


