Skip to content

Python ​

This page demonstrates usage examples of PingDock in Python language.

REST API ​

You can use REST API to interact with PingDock. Import requests library to send POST requests.

python
import requests

def ping_dock(msg: str) -> None:
    url = 'https://api.pingdock.io/ping'
    json_data = {
          'dock_id': '<dock_id>', 
          'secret_key': '<secret_key>',
          'msg': f'{msg}'}
    response = requests.post(url, json=json_data)

Webhook ​

Use webhook alternative in Python or any other service that supports it. Import requests library to send POST requests.

python
import requests
from requests.auth import HTTPBasicAuth

# Target URL (webhook endpoint)
url = "https://api.pingdock.io/webhook"

# JSON body
payload = {
    "msg": "<Your message>"
}

# Basic Auth credentials
username = "<dock_id>"
password = "<secret_key>"

# Send POST request with JSON and Basic Auth
response = requests.post(
    url,
    json=payload,  # automatically encodes to JSON and sets Content-Type: application/json
    auth=HTTPBasicAuth(username, password)
)