# How to use the new api

**URL:** <https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484>\
**Category:** Beta 6.0\
**Created:** [November 23, 2023, 3:04pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484 "2023-11-23T15:04:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![milo](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@milo](https://discourse.pi-hole.net/u/milo)\
**Post date:** [November 23, 2023, 3:04pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484/1 "2023-11-23T15:04:08Z")

</div>

Hello, is there a description how to use the new API?

---

<div class="post-metadata">

**Author:** ![DL6ER](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dl6er/32/281_2.png) [@DL6ER](https://discourse.pi-hole.net/u/DL6ER)\
**Post date:** [November 23, 2023, 3:49pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484/2 "2023-11-23T15:49:46Z")

</div>

There is some general discussion here

[https://github.com/pi-hole/docs/pull/338](https://github.com/pi-hole/docs/pull/338)

with preview here

> **[Pi-hole API - Pi-hole documentation](https://deploy-preview-338--pihole-docs.netlify.app/api/)**

* * *

Your Pi-hole self-hosts a precise API documentation using the OpenAPI standard. This will always match your local Pi-hole's API version and works 100% offline. Check out [https://pi.hole/api/docs](https://pi.hole/api/docs)

You can also check the version of current `development-v6` online if you prefer this:

> **[index - powered by h5ai v0.30.0 (https://larsjung.de/h5ai/)](https://ftl.pi-hole.net/development-v6/docs/#overview)**
>
> index - powered by h5ai v0.30.0 (https://larsjung.de/h5ai/)

---

<div class="post-metadata">

**Author:** ![deHakkelaar](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dehakkelaar/32/674_2.png) [@deHakkelaar](https://discourse.pi-hole.net/u/deHakkelaar)\
**Post date:** [November 23, 2023, 8:59pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484/3 "2023-11-23T20:59:11Z")

</div>

Its easier if you remove the password when playing around eg:

~~`pihole -a -p`~~  
`pihole setpassword`

Here are some examples with **curl** adding and removing an adlist (via HTTP):

**GET:**

```auto
$ curl -s pi.hole/api/lists | jq '.lists[]|.address,.enabled'

"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
true
"https://dehakkelaar.nl/lists/cryptojacking_campaign.list.txt"
true
"https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list.txt"
true
"https://github.com/NCSC-NL/flubot/raw/main/dga/flubot_v4.8_202112.txt"
true

```

**POST:**

```auto
$ curl -s --request POST \
-d '{"address":"https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt","type":"block","enabled":false}' \
pi.hole/api/lists | jq

{
  "lists": [
    {
      "address": "https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt",
      "comment": null,
      "groups": [
        0
      ],
      "enabled": false,
      "id": 14,
      "date_added": 1698716782,
      "date_modified": 1698716782,
      "type": "block",
      "date_updated": 0,
      "number": 0,
      "invalid_domains": 0,
      "abp_entries": 0,
      "status": 0
    }
  ],
  "took": 0.012626886367797852
}

```

**GET:**

```auto
$ curl -s pi.hole/api/lists | jq '.lists[]|.address,.enabled'

"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
true
"https://dehakkelaar.nl/lists/cryptojacking_campaign.list.txt"
true
"https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list.txt"
true
"https://github.com/NCSC-NL/flubot/raw/main/dga/flubot_v4.8_202112.txt"
true
"https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt"
false

```

**DELETE:**

```auto
$ curl -s --request DELETE \
pi.hole/api/lists/https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt
$

```

**GET:**

```auto
$ curl -s pi.hole/api/lists | jq '.lists[]|.address,.enabled'

"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
true
"https://dehakkelaar.nl/lists/cryptojacking_campaign.list.txt"
true
"https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list.txt"
true
"https://github.com/NCSC-NL/flubot/raw/main/dga/flubot_v4.8_202112.txt"
true

```

---

<div class="post-metadata">

**Author:** ![rdwebdesign](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/rdwebdesign/32/51363_2.png) [@rdwebdesign](https://discourse.pi-hole.net/u/rdwebdesign)\
**Post date:** [November 23, 2023, 9:33pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484/4 "2023-11-23T21:33:32Z")

</div>

> [@deHakkelaar](#):
>
> Its easier if you remove the password when playing around eg:
> 
> `pihole -a -p`

**Note:**

The v6 command to change the password is: [`pihole setpassword`](https://github.com/pi-hole/pi-hole/blob/2338c9e916ea77ca58e980338c61a31f801a695d/pihole#L613)

---

<div class="post-metadata">

**Author:** ![deHakkelaar](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dehakkelaar/32/674_2.png) [@deHakkelaar](https://discourse.pi-hole.net/u/deHakkelaar)\
**Post date:** [November 23, 2023, 10:02pm UTC](https://discourse.pi-hole.net/t/how-to-use-the-new-api/66484/5 "2023-11-23T22:02:59Z")

</div>

Old habits die hard 😉

```auto
$ pihole -h
[..]
Options:
  setpassword set the password for the web interface

```
