Skip to content

sterrenb/pihole-api

Repository files navigation

Pi-hole API

Pub Build codecov License

A Flutter library for the Pi-hole API.

Example

The following example prints the summary information after fetching it.

Note: Do not forget to add your own API token if you use authenticated requests.

import 'package:pihole_api/pihole_api.dart';

final pihole = PiholeRepositoryDio(PiholeRepositoryParams(
  baseUrl: "http://pi.hole",
  apiPath: "/admin/api.php",
  apiTokenRequired: true,
  // Find the API token from your Pi-hole admin dashboard while signed in, 
  // e.g. from http://pi.hole/admin/scripts/pi-hole/php/api_token.php.
  apiToken: const String.fromEnvironment(
    "PIHOLE_API_TOKEN",
    defaultValue: "MY_TOKEN",
  ),  
  allowSelfSignedCertificates: false,
  adminHome: "/admin",
));
pihole.fetchSummary(CancelToken()).then((summary) => print(summary.toString()));

Development

The models are built by freezed. To build the models, use build_runner:

flutter pub run build_runner build
# or
flutter pub run build_runner build --delete-conflicting-outputs

Changelog

standard-version --release-as x.y.z

About

A Flutter library for the Pi-hole API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages