The PiDAR API as a Python library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
pidarapi
tests
.gitignore
.travis.yml
LICENSE
README.md
setup.py
tox.ini

README.md

python-pidarapi

The PiDAR API as a Python library

Build Status

Installation

This package is currently not in the PyPI, but you can fetch it from GitHub. In your requirements.txt add the following line:

-e git+https://github.com/aufziehvogel/python-pidarapi.git#egg=pidarapi

For a setup.py file use these lines:

setup(
   # your other options here...
   install_requires=[
      'pidarapi',
   ],
   dependency_links=[
      'https://github.com/aufziehvogel/python-pidarapi/archive/master.zip#egg=pidarapi-0.1',
   ]
)

Usage

The package provides the same functionality as the raw HTTP API.

Ping Management

You can manage your pings from this API. You can create, edit and delete pings as well as retrieve information about pings. See the following code for an example of creating a ping and deleting it again.

from pidarapi.ping import PingApi

api = PingApi('https://pidar.eu', 'your-personal-api-key')

# Create a new Ping
ping_info = api.create_ping({
    'name': 'The Name for your Ping',
    'interval': 3600,
    'grace_period': 0,
})

# And delete it again
api.delete_ping(ping_info['guid'])

Editing a ping:

from pidarapi.ping import PingApi

api = PingApi('https://pidar.eu', 'your-personal-api-key')

# Create a new Ping
ping_info = api.edit_ping('the-guid-of-the-ping', {
    'name': 'The new name',
    'interval': 7200,
    'grace_period': 600,
})

Retrieving information about a ping:

from pidarapi.ping import PingApi

api = PingApi('https://pidar.eu', 'your-personal-api-key')

# Get Ping information
ping_info = api.get_ping('the-guid-of-the-ping')

Ping Notification

The API can also be used to send standard ping notifications to your pings. This is possible either by GUID or alias.

from pidarapi.ping import Ping

pinger = Ping('https://pidar.eu')
pinger.ping('the-guid-of-your-ping')
pinger.ping('username', 'ping-alias')