This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(url): add API url for pi-hole API endpoints
## what - add API url for pi-hole API endpoints - endpoints - summaryRaw - summary - overTimeData10mins - topItems - topClients ## how - used web dev tools to reverse engineer what API calls were made - check reference https://discourse.pi-hole.net/t/pi-hole-api/1863 ## why - These endpoints will be used to interact with pi-hole to get data and statistics ## where ## usage
- Loading branch information
1 parent
9cd3f82
commit d8432cb
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// upstream API obtained from | ||
// https://discourse.pi-hole.net/t/pi-hole-api/1863 | ||
|
||
export const upstreamBaseApiUrl = '/api.php'; | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
/** | ||
* API url to fetch 'summaryRaw' to upstream API. | ||
* Gives statistics in raw format (no number formatting applied). | ||
* | ||
* @remarks No Authorization required | ||
* @see {@link ISummaryRaw} Data format returned | ||
* @returns API URL for upstream API | ||
*/ | ||
export const summaryRaw = () => `${upstreamBaseApiUrl}?summaryRaw`; | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
/** | ||
* API url to fetch 'summary' to upstream API. | ||
* Gives statistics in formatted style | ||
* | ||
* @remarks No Authorization required | ||
* @see {@link ISummary} Data format returned | ||
* @returns API URL for upstream API | ||
*/ | ||
export const summary = () => `${upstreamBaseApiUrl}?summary`; | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
/** | ||
* API url to fetch 'overTimeData10mins' to upstream API. | ||
* Data needed for generating the domains/ads over time graph on the Pi-hole web dashboard | ||
* | ||
* @remarks No Authorization required | ||
* @see {@link IOverTimeData10minutes} Data format returned | ||
* @returns API URL for upstream API | ||
*/ | ||
export const overTimeData10mins = () => `${upstreamBaseApiUrl}?overTimeData10mins`; | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
/** | ||
* API url to fetch 'topItems' to upstream API. | ||
* Data needed for generating the Top Domain and Top Advertisers Lists | ||
* | ||
* @remarks Authorization required | ||
* @see {@link ITopItems} Data format returned | ||
* @param numEntries - Number of entries to return. Default is 10 | ||
* @returns API URL for upstream API | ||
*/ | ||
export const topItems = (numEntries = 10) => `${upstreamBaseApiUrl}?topItems=${numEntries}`; | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
/** | ||
* API url to fetch 'getQuerySources' to upstream API. | ||
* Data needed for generating the Top Clients list | ||
* | ||
* @remarks Authorization required | ||
* @see {@link IGetQuerySources} Data format returned | ||
* @param numEntries - Number of entries to return. Default is 10 | ||
* @returns API URL for upstream API | ||
*/ | ||
export const topClients = (numEntries = 10) => `${upstreamBaseApiUrl}?topClients=${numEntries}`; |