NicoFgrx / pihole-api-go

Simple go client for pihole API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pihole-api-go

WIP : pihole-api-go is a go Client for interacting with Pihole by https://pi-hole.net/.

Installation

pihole-api-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/NicoFgrx/pihole-api-go

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

import "github.com/NicoFgrx/pihole-api-go/api"

and run go get without parameters.

Usage

import pihole "github.com/NicoFgrx/pihole-api-go/api"

Construct a new pihole client, then use the various services on the client to access different parts of the Pihole API. For example:

url := "http://localhost:8080/admin/api.php" // must be http[s]://<IP>:<port>/admin/api.php
key := "xxx" // find the token on the web UI in Settings>API

client := pihole.NewClient(url, key)

// Get all custom dns defined on the pihole
customdns_lst, err := client.GetAllCustomDNS()

You can find more examples in examples folder.

Development

Feel free to contribute according to the CODE_OF_CONDUCT

Setting up the development environment

You can find a docker-compose file in docker_compose folder.

cd docker_compose
docker-compose up

Default credential is example and only web UI port is listening on http://localhost:8080.

License

This library is distributed under the MIT licence found in the LICENSE file.

About

Simple go client for pihole API

License:MIT License


Languages

Language:Go 100.0%