Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
feat(url): add API url for pi-hole API endpoints
Browse files Browse the repository at this point in the history
  ## 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
Clumsy-Coder committed Aug 20, 2023
1 parent 9cd3f82 commit d8432cb
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/utils/url/upstream.ts
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}`;

0 comments on commit d8432cb

Please sign in to comment.