定制 aseemann/pihole-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aseemann/pihole-api-client

Composer 安装命令:

composer require aseemann/pihole-api-client

包简介

The Pi-hole API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). Our API has predictable resource-oriented URLs, accepts and returns reliable UTF-8 [JavaScript Object Notation (JSON)-encoded](http://www.json.org/) data for all API responses, and uses standard

README 文档

README

The Pi-hole API is organized around REST. Our API has predictable resource-oriented URLs, accepts and returns reliable UTF-8 JavaScript Object Notation (JSON)-encoded data for all API responses, and uses standard HTTP response codes and verbs. Most (but not all) endpoints require authentication. API endpoints requiring authentication will fail with code 401 Unauthorized when used outside a valid session.

For more information, please visit https://discourse.pi-hole.net.

Installation & Usage

Requirements

PHP 8.1 and later.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/aseemann/pihole-api-client.git"
    }
  ],
  "require": {
    "aseemann/pihole-api-client": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/aseemann/pihole-api-client/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');



// Configure API key authorization: x_header_sid
$config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKey('X-FTL-SID', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FTL-SID', 'Bearer');

// Configure API key authorization: query_sid
$config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKey('sid', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKeyPrefix('sid', 'Bearer');

// Configure API key authorization: cookie_sid
$config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKey('sid', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKeyPrefix('sid', 'Bearer');

// Configure API key authorization: header_sid
$config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKey('sid', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Aseemann\PiholeApi\Configuration::getDefaultConfiguration()->setApiKeyPrefix('sid', 'Bearer');


$apiInstance = new Aseemann\PiholeApi\Api\ActionsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->actionFlusharp();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ActionsApi->actionFlusharp: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://pi.hole:443/api

ClassMethodHTTP requestDescription
ActionsApiactionFlusharpPOST /action/flush/arpFlush the network table
ActionsApiactionFlushlogsPOST /action/flush/logsFlush the DNS logs
ActionsApiactionGravityPOST /action/gravityRun gravity
ActionsApiactionRestartdnsPOST /action/restartdnsRestart pihole-FTL
AuthenticationApiaddAppGET /auth/appCreate new application password
AuthenticationApiaddAuthPOST /authSubmit password for login
AuthenticationApideleteAuthSessionDELETE /auth/session/{id}Delete session by ID
AuthenticationApideleteGroupsDELETE /authDelete session
AuthenticationApigetAuthGET /authCheck if authentication is required
AuthenticationApigetAuthSessionsGET /auth/sessionsList of all current sessions
AuthenticationApigetAuthTotpGET /auth/totpSuggest new TOTP credentials
ClientManagementApiaddClientPOST /clientsAdd new client
ClientManagementApibatchDeleteClientsPOST /clients:batchDeleteDelete multiple clients
ClientManagementApideleteClientDELETE /clients/{client}Delete client
ClientManagementApigetClientSuggestionsGET /clients/_suggestionsGet client suggestions
ClientManagementApigetClientsGET /clients/{client}Get clients
ClientManagementApireplaceClientPUT /clients/{client}Replace client
DHCPApideleteDhcpDELETE /dhcp/leases/{ip}Remove DHCP lease
DHCPApigetDhcpGET /dhcp/leasesGet currently active DHCP leases
DNSControlApigetBlockingGET /dns/blockingGet current blocking status
DNSControlApisetBlockingPOST /dns/blockingChange current blocking status
DocumentationApigetDocsGET /docsGet the embedded API documentation rendered as HTML
DomainManagementApiaddDomainPOST /domains/{type}/{kind}Add new domain
DomainManagementApibatchDeleteDomainsPOST /domains:batchDeleteDelete multiple domains
DomainManagementApideleteDomainDELETE /domains/{type}/{kind}/{domain}Delete domain
DomainManagementApigetDomainsGET /domains/{type}/{kind}/{domain}Get domain
DomainManagementApireplaceDomainPUT /domains/{type}/{kind}/{domain}Replace domain
FTLInformationApideleteMessageDELETE /info/messages/{message_id}Delete Pi-hole diagnosis message
FTLInformationApigetClientGET /info/clientGet information about requesting client
FTLInformationApigetDbinfoGET /info/databaseGet info about long-term database
FTLInformationApigetDnsLogGET /logs/dnsmasqGet DNS log content
FTLInformationApigetEndpointsGET /endpointsGet list of available API endpoints
FTLInformationApigetFtlLogGET /logs/ftlGet DNS log content
FTLInformationApigetFtlinfoGET /info/ftlGet info about various ftl parameters
FTLInformationApigetHostinfoGET /info/hostGet info about various host parameters
FTLInformationApigetLogininfoGET /info/loginLogin page related information
FTLInformationApigetMessagesGET /info/messagesGet Pi-hole diagnosis messages
FTLInformationApigetMessagesCountGET /info/messages/countGet count of Pi-hole diagnosis messages
FTLInformationApigetMetricsinfoGET /info/metricsGet metrics info
FTLInformationApigetSensorsGET /info/sensorsGet info about various sensors
FTLInformationApigetSysteminfoGET /info/systemGet info about various system parameters
FTLInformationApigetVersionGET /info/versionGet Pi-hole version
FTLInformationApigetWebserverLogGET /logs/webserverGet DNS log content
GroupManagementApiaddGroupPOST /groupsAdd new group
GroupManagementApibatchDeleteGroupsPOST /groups:batchDeleteDelete multiple groups
GroupManagementApideleteGroupDELETE /groups/{name}Delete group
GroupManagementApigetGroupsGET /groups/{name}Get groups
GroupManagementApireplaceGroupPUT /groups/{name}Replace group
ListManagementApiaddListPOST /listsAdd new list
ListManagementApibatchDeleteListsPOST /lists:batchDeleteDelete lists
ListManagementApideleteListsDELETE /lists/{list}Delete list
ListManagementApigetListsGET /lists/{list}Get lists
ListManagementApigetSearchGET /search/{domain}Search domains in Pi-hole's lists
ListManagementApireplaceListsPUT /lists/{list}Replace list
MetricsApigetActivityMetricsGET /historyGet activity graph data
MetricsApigetActivityMetricsDatabaseGET /history/databaseGet activity graph data (long-term data)
MetricsApigetClientMetricsGET /history/clientsGet per-client activity graph data
MetricsApigetClientMetricsDatabaseGET /history/database/clientsGet per-client activity graph data (long-term data)
MetricsApigetMetricsDatabaseQueryTypesGET /stats/database/query_typesGet query types (long-term database)
MetricsApigetMetricsDatabaseSummaryGET /stats/database/summaryGet database content details
MetricsApigetMetricsDatabaseTopClientsGET /stats/database/top_clientsGet top clients (long-term database)
MetricsApigetMetricsDatabaseTopDomainsGET /stats/database/top_domainsGet top domains (long-term database)
MetricsApigetMetricsQueryTypesGET /stats/query_typesGet query types
MetricsApigetMetricsRecentBlockedGET /stats/recent_blockedGet most recently blocked domain
MetricsApigetMetricsSummaryGET /stats/summaryGet overview of Pi-hole activity
MetricsApigetMetricsTopClientsGET /stats/top_clientsGet top clients
MetricsApigetMetricsTopDomainsGET /stats/top_domainsGet top domains
MetricsApigetMetricsUpstreamsGET /stats/upstreamsGet metrics about Pi-hole's upstream destinations
MetricsApigetMetricsUpstreamsDatabaseGET /stats/database/upstreamsGet metrics about Pi-hole's upstream destinations (long-term database)
MetricsApigetQueriesGET /queriesGet queries
MetricsApigetSuggestionsGET /queries/suggestionsGet query filter suggestions
NetworkInformationApideleteDeviceDELETE /network/devices/{device_id}Delete a device from the network table
NetworkInformationApigetGatewayGET /network/gatewayGet info about the gateway of your Pi-hole
NetworkInformationApigetInterfacesGET /network/interfacesGet info about the interfaces of your Pi-hole
NetworkInformationApigetNetworkGET /network/devicesGet info about the devices in your local network as seen by your Pi-hole
NetworkInformationApigetRoutesGET /network/routesGet info about the routes of your Pi-hole
PADDApigetPaddGET /paddGet summarized data for PADD
PiHoleConfigurationApiaddArrayItemPUT /config/{element}/{value}Add config array item
PiHoleConfigurationApideleteArrayItemDELETE /config/{element}/{value}Delete config array item
PiHoleConfigurationApigetConfigElemGET /config/{element}Get specific part of current configuration of your Pi-hole
PiHoleConfigurationApigetPiholeConfigGET /configGet current configuration of your Pi-hole
PiHoleConfigurationApigetTeleporterGET /teleporterExport Pi-hole settings
PiHoleConfigurationApipatchConfigPATCH /configChange configuration of your Pi-hole
PiHoleConfigurationApipostTeleporterPOST /teleporterImport Pi-hole settings

Models

Authorization

Authentication schemes defined for the API:

query_sid

  • Type: API key
  • API key parameter name: sid
  • Location: URL query string

cookie_sid

  • Type: API key
  • API key parameter name: sid
  • Location:

header_sid

  • Type: API key
  • API key parameter name: sid
  • Location: HTTP header

x_header_sid

  • Type: API key
  • API key parameter name: X-FTL-SID
  • Location: HTTP header

query_password

  • Type: API key
  • API key parameter name: password
  • Location: URL query string

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: 6.0
    • Generator version: 7.13.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

aseemann/pihole-api-client 适用场景与选型建议

aseemann/pihole-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aseemann/pihole-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aseemann/pihole-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 aseemann/pihole-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: unlicense
  • 更新时间: 2025-04-01