APiHole


NameAPiHole JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/sdebby/APiHole
SummaryAPI module for Pi Hole
upload_time2024-03-14 18:47:42
maintainer
docs_urlNone
authorShmulik Debby
requires_python
licenseMIT
keywords pihole pi.hole api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# APiHole

This is an easy python API module for comunicating with Pi Hole through API.
Works with AdminLTE v. 3

* Rev 0.0.2 update by Dan Taeyoung

## Install:

```bash
pip install APiHole
```

## Get your Pi Hole API key from here:

```bash
sudo cat /etc/pihole/setupVars.conf | grep PASSWORD
```

## Usage
```python
from APiHole import PiHole

PiHoleAPI='your pi hole API key'
PiIP='your pi hole IP'

# Print API version (good for testing communication), (return string)
print(PiHole.GetVer(PiIP))

# Get PiHole summary , (return dict)
PiHole.GetSummary(PiIP,PiHoleAPI)

# Get PiHole gravity status , (return dict)
print(PiHole.GetGravity(PiIP,PiHoleAPI))

# Get PiHole status, (return string)
PiHole.GetStatus(PiIP)

# Get PiHole 7 top items, split and convert to list (return dict)
Items=PiHole.GetTopItems(PiIP,PiHoleAPI,7)
if not len(Items) == 0:
    ItemsTop=Items['top_queries']
    resultListTOP = list(ItemsTop.items())
    rtnTOP=[]
    ItemsADS=Items['top_ads']
    resultListADS = list(ItemsTop.items())
    rtnTOP=[]
    rtnADS=[]
    for l in range(len(resultListTOP)):
        rtnTOP.append(str(resultListTOP[l][0])+' : '+str(resultListTOP[l][1]))
        rtnADS.append(str(resultListADS[l][0])+' : '+str(resultListADS[l][1]))

    print('top_queries\n'+str(rtnTOP))
    print('top_ads\n'+str(rtnADS))

# Enable PiHole (return string)
PiHole.Enable(PiIP,PiHoleAPI)

# Disable PiHole for 2 sec (return string)
PiHole.Disable(PiIP,PiHoleAPI,2)

# Get top clients (return string)
PiHole.GetTopClients(PiIP,PiHoleAPI)

# Add google.com to white list (return boolean)
PiHole.AddWhite(PiIP,PiHoleAPI,'google.com')

# Add google.com to block list (return boolean)
PiHole.AddBlack(PiIP,PiHoleAPI,'google.com')

# Get recent blocked domain, (return string)
PiHole.GetRecentBlocked(PiIP,PiHoleAPI)

# Get destinations in %, (return dict)
PiHole.GetDestination(PiIP,PiHoleAPI)

# Get query types in %, (return dict)
PiHole.GetQueryTypes(PiIP,PiHoleAPI)

# Get clients names, (return dict)
PiHole.GetClientNames(PiIP,PiHoleAPI)

# Get data of clients over time, (return dict)
PiHole.GetOverTimeDataClients(PiIP,PiHoleAPI)

# Get pi hole DNS port, (return string)
PiHole.GetDnsPort(PiIP,PiHoleAPI)

# Get pi hole chche info, (return dict)
PiHole.GetCacheInfo(PiIP,PiHoleAPI)

# Get pi hole data of 10 min 
PiHole.GetOverTimeData10mins(PiIP,PiHoleAPI)

# Remove 'google.com' from block list
PiHole.RemoveBlock(PiIP,PiHoleAPI,'google.com')

# Add facebook regex to block list (return boolean)
PiHole.AddRegexBlock(PiIP,PiHoleAPI,'facebook')

# Remove facebook regex from block list (return boolean)
PiHole.RemoveRegexBlock(PiIP,PiHoleAPI,'facebook')
```
### TODOs


### Change log
* rev 0.0.1 - Initial release.
* rev 0.0.2 (by Dan Taeyoung)
	* Typo fix.
	* Add RemoveBlock function.
	* Add AddRegexBlock function.
	* Add RemoveRegexBlock function.

## Feedback

If you have any feedback, please reach out to us at shmulik.debby@gmail.com

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sdebby/APiHole",
    "name": "APiHole",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "PiHole,pi.hole,API",
    "author": "Shmulik Debby",
    "author_email": "shmulik.debby@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d1/ce/0739993734471c0c4d862c3944d3f56be8c0f7893a538fc17e3dae563bfa/APiHole-0.0.2.tar.gz",
    "platform": null,
    "description": "\r\n# APiHole\r\n\r\nThis is an easy python API module for comunicating with Pi Hole through API.\r\nWorks with AdminLTE v. 3\r\n\r\n* Rev 0.0.2 update by Dan Taeyoung\r\n\r\n## Install:\r\n\r\n```bash\r\npip install APiHole\r\n```\r\n\r\n## Get your Pi Hole API key from here:\r\n\r\n```bash\r\nsudo cat /etc/pihole/setupVars.conf | grep PASSWORD\r\n```\r\n\r\n## Usage\r\n```python\r\nfrom APiHole import PiHole\r\n\r\nPiHoleAPI='your pi hole API key'\r\nPiIP='your pi hole IP'\r\n\r\n# Print API version (good for testing communication), (return string)\r\nprint(PiHole.GetVer(PiIP))\r\n\r\n# Get PiHole summary , (return dict)\r\nPiHole.GetSummary(PiIP,PiHoleAPI)\r\n\r\n# Get PiHole gravity status , (return dict)\r\nprint(PiHole.GetGravity(PiIP,PiHoleAPI))\r\n\r\n# Get PiHole status, (return string)\r\nPiHole.GetStatus(PiIP)\r\n\r\n# Get PiHole 7 top items, split and convert to list (return dict)\r\nItems=PiHole.GetTopItems(PiIP,PiHoleAPI,7)\r\nif not len(Items) == 0:\r\n    ItemsTop=Items['top_queries']\r\n    resultListTOP = list(ItemsTop.items())\r\n    rtnTOP=[]\r\n    ItemsADS=Items['top_ads']\r\n    resultListADS = list(ItemsTop.items())\r\n    rtnTOP=[]\r\n    rtnADS=[]\r\n    for l in range(len(resultListTOP)):\r\n        rtnTOP.append(str(resultListTOP[l][0])+' : '+str(resultListTOP[l][1]))\r\n        rtnADS.append(str(resultListADS[l][0])+' : '+str(resultListADS[l][1]))\r\n\r\n    print('top_queries\\n'+str(rtnTOP))\r\n    print('top_ads\\n'+str(rtnADS))\r\n\r\n# Enable PiHole (return string)\r\nPiHole.Enable(PiIP,PiHoleAPI)\r\n\r\n# Disable PiHole for 2 sec (return string)\r\nPiHole.Disable(PiIP,PiHoleAPI,2)\r\n\r\n# Get top clients (return string)\r\nPiHole.GetTopClients(PiIP,PiHoleAPI)\r\n\r\n# Add google.com to white list (return boolean)\r\nPiHole.AddWhite(PiIP,PiHoleAPI,'google.com')\r\n\r\n# Add google.com to block list (return boolean)\r\nPiHole.AddBlack(PiIP,PiHoleAPI,'google.com')\r\n\r\n# Get recent blocked domain, (return string)\r\nPiHole.GetRecentBlocked(PiIP,PiHoleAPI)\r\n\r\n# Get destinations in %, (return dict)\r\nPiHole.GetDestination(PiIP,PiHoleAPI)\r\n\r\n# Get query types in %, (return dict)\r\nPiHole.GetQueryTypes(PiIP,PiHoleAPI)\r\n\r\n# Get clients names, (return dict)\r\nPiHole.GetClientNames(PiIP,PiHoleAPI)\r\n\r\n# Get data of clients over time, (return dict)\r\nPiHole.GetOverTimeDataClients(PiIP,PiHoleAPI)\r\n\r\n# Get pi hole DNS port, (return string)\r\nPiHole.GetDnsPort(PiIP,PiHoleAPI)\r\n\r\n# Get pi hole chche info, (return dict)\r\nPiHole.GetCacheInfo(PiIP,PiHoleAPI)\r\n\r\n# Get pi hole data of 10 min \r\nPiHole.GetOverTimeData10mins(PiIP,PiHoleAPI)\r\n\r\n# Remove 'google.com' from block list\r\nPiHole.RemoveBlock(PiIP,PiHoleAPI,'google.com')\r\n\r\n# Add facebook regex to block list (return boolean)\r\nPiHole.AddRegexBlock(PiIP,PiHoleAPI,'facebook')\r\n\r\n# Remove facebook regex from block list (return boolean)\r\nPiHole.RemoveRegexBlock(PiIP,PiHoleAPI,'facebook')\r\n```\r\n### TODOs\r\n\r\n\r\n### Change log\r\n* rev 0.0.1 - Initial release.\r\n* rev 0.0.2 (by Dan Taeyoung)\r\n\t* Typo fix.\r\n\t* Add RemoveBlock function.\r\n\t* Add AddRegexBlock function.\r\n\t* Add RemoveRegexBlock function.\r\n\r\n## Feedback\r\n\r\nIf you have any feedback, please reach out to us at shmulik.debby@gmail.com\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "API module for Pi Hole",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/sdebby/APiHole"
    },
    "split_keywords": [
        "pihole",
        "pi.hole",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d1ce0739993734471c0c4d862c3944d3f56be8c0f7893a538fc17e3dae563bfa",
                "md5": "12932dd85d819c9fd955b24f844b6c12",
                "sha256": "52ffc9e9a06c2a225dd4f28cf6b989354b14fad191ae6de781f66c14dc89443e"
            },
            "downloads": -1,
            "filename": "APiHole-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "12932dd85d819c9fd955b24f844b6c12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5120,
            "upload_time": "2024-03-14T18:47:42",
            "upload_time_iso_8601": "2024-03-14T18:47:42.572767Z",
            "url": "https://files.pythonhosted.org/packages/d1/ce/0739993734471c0c4d862c3944d3f56be8c0f7893a538fc17e3dae563bfa/APiHole-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-14 18:47:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sdebby",
    "github_project": "APiHole",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "apihole"
}
        
Elapsed time: 0.26672s