# Top list in command line

**URL:** <https://discourse.pi-hole.net/t/top-list-in-command-line/16466>\
**Category:** Implemented\
**Created:** [January 25, 2019, 7:56pm UTC](https://discourse.pi-hole.net/t/top-list-in-command-line/16466 "2019-01-25T19:56:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nielsranosch](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/n/ea5d25/32.png) [@nielsranosch](https://discourse.pi-hole.net/u/nielsranosch)\
**Post date:** [January 25, 2019, 7:56pm UTC](https://discourse.pi-hole.net/t/top-list-in-command-line/16466/1 "2019-01-25T19:56:22Z")

</div>

Hello!

Thank you for making pi-hole!

Being able to see the list of most requested domains in the webinterface is nice, but it would be even better for my setup if I were able to get that list on the command line or in a text file. More specifically, I would like to generate a list of the top (maybe 50, maybe more) most requested domains of the last 24 hours and another list over the last 7 days.

Some background of what I am trying to do: Right now, my RPi is running both pi-hole and unbound. The latter acting as a proxy to enable DNS-over-TLS. Unfortunately this is very slow, which is why I forced unbounds cache time to 24 hours. To increase performance further my idea was to renew the cache of the most requested domains every night. That way, those domains would always be answered from cache and never had to be queried when a client is trying to access them. Maybe doing this every 24 hours is not enough and I will change it to every 6 hours, simultaneously lowering the cache time.

In short, what I am asking for is something like this:  
# pihole --top-domains -n 4 -h 24 --show-count  
connectivitycheck.gstatic.com 2034  
mqtt-mini.facebook.com 1972  
mtalk.google.com 1720  
api-global.netflix.com 992

Is that already possible? If not, would you consider implementing it?

Cheers,  
Niels

---

<div class="post-metadata">

**Author:** ![DanSchaper](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/danschaper/32/91_2.png) [@DanSchaper](https://discourse.pi-hole.net/u/DanSchaper)\
**Post date:** [January 25, 2019, 7:57pm UTC](https://discourse.pi-hole.net/t/top-list-in-command-line/16466/2 "2019-01-25T19:57:38Z")

</div>

Take a look at the options in FTLDNS:

[https://docs.pi-hole.net/ftldns/telnet-api/](https://docs.pi-hole.net/ftldns/telnet-api/)

---

<div class="post-metadata">

**Author:** ![yubiuser](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/yubiuser/32/12100_2.png) [@yubiuser](https://discourse.pi-hole.net/u/yubiuser)\
**Post date:** [June 9, 2020, 10:22am UTC](https://discourse.pi-hole.net/t/top-list-in-command-line/16466/6 "2020-06-09T10:22:54Z")

</div>

Can be done easily via sqlite

24h

```auto
sqlite3 /etc/pihole/pihole-FTL.db "select domain, count(domain) from queries where timestamp>=strftime('%s','now')-86400 group by domain order by count(domain) desc Limit 4"

```

7d

```auto
sqlite3 /etc/pihole/pihole-FTL.db "select domain, count(domain) from queries where timestamp>=strftime('%s','now')-604800 group by domain order by count(domain) desc Limit 4"

```

---

<div class="post-metadata">

**Author:** ![yubiuser](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/yubiuser/32/12100_2.png) [@yubiuser](https://discourse.pi-hole.net/u/yubiuser)\
**Post date:** [June 9, 2020, 10:23am UTC](https://discourse.pi-hole.net/t/top-list-in-command-line/16466/7 "2020-06-09T10:23:06Z")

</div>


