{"id":21082,"library":"cronitor","title":"Cronitor Python Client","description":"A lightweight Python client for Cronitor, providing monitoring and alerting for cron jobs, background jobs, and API endpoints. Current version 4.9.0, released May 2025. Active development with occasional minor releases.","status":"active","version":"4.9.0","language":"python","source_language":"en","source_url":"https://github.com/cronitorio/cronitor-python","tags":["monitoring","cron","cronitor","scheduling","alerts"],"install":[{"cmd":"pip install cronitor","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client for API calls","package":"requests","optional":false}],"imports":[{"note":"Direct import of Cronitor class is the standard pattern.","wrong":"import cronitor","symbol":"Cronitor","correct":"from cronitor import Cronitor"},{"note":"ping is a module-level function, not a submodule.","wrong":"import cronitor.ping","symbol":"ping","correct":"from cronitor import ping"}],"quickstart":{"code":"import os\nfrom cronitor import Cronitor\n\napi_key = os.environ.get('CRONITOR_API_KEY', '')\nif not api_key:\n    raise ValueError('CRONITOR_API_KEY environment variable not set')\n\ncronitor = Cronitor(api_key=api_key)\n\n# Create a monitor\nmonitor = cronitor.monitors.create(name='My Job', schedule='*/5 * * * *')\n\n# Ping the monitor\ncronitor.ping(monitor.key, state='run')\nprint('Job started.')","lang":"python","description":"Initialize the client with your API key, create a monitor, and send a run ping."},"warnings":[{"fix":"Use `cronitor.monitors.create(name, schedule)` instead of direct methods on the Cronitor class.","message":"In v4.0, the client was rewritten. The old import pattern `from cronitor import Cronitor` still works, but the API for creating monitors changed: use `cronitor.monitors.create()` instead of `Cronitor(api_key).create_monitor()`.","severity":"breaking","affected_versions":">=4.0.0,<5.0.0"},{"fix":"Set CRONITOR_API_KEY environment variable or pass `api_key` argument to Cronitor() constructor.","message":"API key must be set via environment variable or passed explicitly. The client does not auto-read from .env files.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from cronitor import ping` and call `ping(monitor_key, state='...')` instead of `cronitor.pings.create(...)`.","message":"The `pings.create()` method is deprecated in favor of the module-level `ping()` function.","severity":"deprecated","affected_versions":">=4.5.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure CRONITOR_API_KEY environment variable is set to a valid key from your Cronitor account, or pass `api_key` explicitly.","cause":"Invalid or missing API key.","error":"cronitor.errors.CronitorRequestError: 401 Unauthorized"},{"fix":"Double-check the monitor key and the endpoint URL. For pings, ensure the monitor key is correct.","cause":"The monitor key does not exist or the API endpoint is misspelled.","error":"cronitor.errors.CronitorRequestError: 404 Not Found"},{"fix":"Upgrade to latest version: `pip install --upgrade cronitor`. In older versions, use `import cronitor; cronitor.api_key = '...'`.","cause":"Using an older version of the library (<4.0) that doesn't have the Cronitor class.","error":"ImportError: cannot import name 'Cronitor' from 'cronitor'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}