# Call to $contactApi-\>getList() returns too many results

**URL:** https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911
**Category:** Product Support
**Created:** [June 20, 2021, 9:40am UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911 "2021-06-20T09:40:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)
#### Post date: [June 20, 2021, 9:40am UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911/1 "2021-06-20T09:40:42Z")

</div>

I’m using Mautic 3.3 with the latest API and want to check my contacts agains informations i stored elsewhere (check if email, name, company, and so on fits with div. user directories).  
I found that calling  
`getList('email='.$email);`  
for every email to check in an iteration takes muuuch to long and so i decided to load all contacts in one go, or by chunks (using the start and limit params) and compare then. But when i simply issue an  
`$contactApi->getList();`  
without any searchfilter (which in my opinion should return all contacts) i got 9047 in ‘total’

This puzzles me, as i only got 1689 contacts in my Mautic. Even when i look into the database it gave me that count of 9047:

```auto
SELECT count(*) FROM leads;

```

Any ideas here?

---

<div class="post-metadata">

### Author: ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)
#### Post date: [June 20, 2021, 6:01pm UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911/2 "2021-06-20T18:01:41Z")

</div>

I guess i found something about the strange number of contacts… it seems that Mautic stores also so called “anonymous contacts” in that table. If i click on “Toggle anonymous contacts” icon on the top-right of the contacts-list, or enter the search-term “is:anonymous”, i get 7367 results. And 9047 - 7367 = 1680 which is the expected number of contacts.

So, first thing to do for me is to only let getList() return non-anonymous contacts. It think i could be done using this search filter:

```auto
!(is:anonymous)

```

But my first try ends up in an “memory exhausted” error on the Webserver ☹

But where are all those anons come from? It seems that Mautic puts the IP address of every contact to it into that table. So whenever somebody hits my Mautic it will be recorded, regardless if that lead to any usefull or not.

The majority of my anon contacts tried to access this URL  
`https://mautic.mydomain.com/wp/wp-login.php`  
which looks more like Script-Kiddy Wordpress bruteforce.  
So first thing for me is to lead this URL to a 404 on the Nginx 🙂  
Next thing would be to remove all that stuff from the database.

---

<div class="post-metadata">

### Author: ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)
#### Post date: [June 20, 2021, 6:10pm UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911/3 "2021-06-20T18:10:42Z")

</div>

`SELECT count(*) FROM mautic.lead_event_log WHERE properties LIKE '%wp_login.php%';`  
gave out “only” 436 brutes. But there are many more unwanted page-queries in the log.

How can i prevent Mautic from creating a lead from every page-request?  
And how can i cleanup my leads? Just using SQL?

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [June 21, 2021, 5:29am UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911/4 "2021-06-21T05:29:36Z")

</div>

Hi, you can also create a campaign that takes care of it.

> [@There's presumably bot accessing media and mautic registers new anonymous contacts. Thus, the contact ID builds up so quickly](https://forum.mautic.org/t/theres-presumably-bot-accessing-media-and-mautic-registers-new-anonymous-contacts-thus-the-contact-id-builds-up-so-quickly/19236/5):
>
> Are you getting a lot of the same IP or is it just one ip logging one hit…I am getting tons of IPs that are visitors anonymous (not bots based on the useragent) when Mautic should have placed all the same IP in one record…they are making a new record for each one… sometimes 50-60 in a row…killing my db… Also you can montior the useragent yourself to see if they are bots or non browsers… Be careful with the blocking and deleteing… since if you confirm they are browsers and the keep hitting your …

---

<div class="post-metadata">

### Author: ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)
#### Post date: [June 21, 2021, 8:19am UTC](https://forum.mautic.org/t/call-to-contactapi-getlist-returns-too-many-results/19911/5 "2021-06-21T08:19:59Z")

</div>

I think about how to formulate this as SQL… what do you want to get out of this information?  
The challenge is to distinguish between wanted and unwanted access to Mautic and filter out the unwanted (brute forces, scanner, bots), right?  
I would say, every request Mautic cannot handle, because the URL leads to something that does not exist, should not create a lead and simply be ignored without a trace.
