Skip to main content

Lightweight wrapper around Statuscake’s APIs. Heavily inspired by the OVH python client https://github.com/ovh/python-ovh

# -*- encoding: utf-8 -*-

import statuscake_api

client = statuscake_api.Client(
    api_key='<api_key>',
)

# Print nice welcome message
print("Welcome", client.get('/uptime'))

Installation

The python wrapper works with Python 2.7 and Python 3.4+.

The easiest way to get the latest stable release is to grab it from pypi using pip.

pip install statuscake_api

Alternatively, you may get latest development version directly from Git.

pip install -e git+https://github.com/alkivi-sas/python-statuscake-api.git#egg=statuscake_api

Example Usage

1. Create an application

Go to your statuscake account and get your API KEY

2. Configure your application

The easiest and safest way to use your application’s credentials is to create an statuscake.conf configuration file in application’s working directory. Here is how it looks like:

[default]
; general configuration: default endpoint
endpoint=my_user

[my_user]
; configuration specific to 'my_user' endpoint
api_key=my_api_key

Depending on the API you want to use, you may set the several endpoint to handle severals accounts

Get all tests

# -*- encoding: utf-8 -*-

import statuscake_api

# create a client
client = statuscake_api.Client()

finished = False
page = 1
tests = []
while not finished:
    params = {'page': page}

    response = client.get('/uptime', **params)

    test = response['data']
    tests = tests + test

    if 'metadata' in response:
        page_count = response['metadata']['page_count']
        if page < page_count:
            page += 1
        else:
            finished = True
    else:
        finished = True
print(f'We have fetched {len(tests)}')

Add new test

When array in parameters, you need to add [] for the parameter

# -*- encoding: utf-8 -*-

import statuscake_api

# create a client
client = statuscake_api.Client()

new_test = {
     'name': 'test-connection',
     'test_type': 'PING',
     'website_url': '8.8.8.8',
     'check_rate': 60,
     'tags_csv': 'test,api',
     'contact_groups_csv': '31173',
     'regions[]': ['paris', 'london'],
 }
test = client.post('/uptime', **new_test)

Environment vars and predefined configuration files

Alternatively it is suggested to use configuration files or environment variables so that the same code may run seamlessly in multiple environments. Production and development for instance.

This wrapper will first look for direct instantiation parameters then STATUSCAKE_ENDPOINT, STATUSCAKE_API_KEY environment variables. If either of these parameter is not provided, it will look for a configuration file of the form:

[default]
; general configuration: default endpoint
endpoint=statuscake-eu

[statuscake-eu]
; configuration specific to 'statuscake-eu' endpoint
api_key=my_api_key

The client will successively attempt to locate this configuration file in

  1. Current working directory: ./statuscake.conf

  2. Current user’s home directory ~/.statuscake.conf

  3. System wide configuration /etc/statuscake.conf

This lookup mechanism makes it easy to overload credentials for a specific project or user.

Example usage:

client = statuscake_api.Client()

Custom configuration file

You can also specify a custom configuration file. With this method, you won’t be able to inherit values from environment.

Example usage:

client = statuscake_api.Client(config_file='/my/config.conf')

Metadata

Release files for statuscake-api 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for statuscake-api 0.1.1
File Interpreter ABI Platform
statuscake_api-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / statuscake_api-0.1.1-py2.py3-none-any.whl

Download URL statuscake_api-0.1.1-py2.py3-none-any.whl
Size 10.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3b3e55d50e621055615b1cb29c60437cb0ac1e5d040bd4ca583f81f0e7b90bd5
BLAKE2b-256 checksum
How to use checksums
4006506b1a41a000fbd9d66db658e90b072a3ddfe9282551bdc546a03fdc0f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Security for statuscake-api 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page