Skip to main content

SDK in Python to simplify access Sentry API (https://docs.sentry.io/api/)

Project description

sentry-api-python

PyPI Python License

This project aims to simplify communication with Sentry REST API.

It is in quite early stage, our approach is simple. We cover first endpoints that we use for our tools. But new PRs are more than welcome.

Installation

pip install sentry-api-python

Example of use

Create project

from sentry_api.api import SentryApi

sentry_api = SentryApi(
    organization_slug="my-org",
    token="<Your Auth Token https://docs.sentry.io/api/auth/>",
)
response = sentry_api.projects.create(
    team_slug="backend",
    project=dict(name="My first project")
)

Create alert with Slack + Linear integration

from sentry_api.api import SentryApi

sentry_api = SentryApi(
    organization_slug="my-org",
    token="<Your Auth Token https://docs.sentry.io/api/auth/>",
    endpoint_url="https://sentry.io/api/0/",
)

response = sentry_api.project_rules.create(
    project_slug="my-first-project",
    rule={
        "name": "Prod issues",
        "owner": "team:<id of team>",
        "environment": "prod",
        "actionMatch": "any",
        "filterMatch": "all",
        "frequency": 10080,  # One week
        "conditions": [
            {"id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"},
            {"id": "sentry.rules.conditions.regression_event.RegressionEventCondition"},
        ],
        "actions": [
            {
                "workspace": "<slack workspace>",
                "id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
                "channel": "#alerts-production",
                "channel_id": "<https://docs.sentry.io/product/integrations/notification-incidents/slack/#rate-limiting-error>",
            },
            {
                "id": "sentry.rules.actions.notify_event_sentry_app.NotifyEventSentryAppAction",
                "sentryAppInstallationUuid": "<app installation here>",
                "settings": [
                    {"name": "teamId", "value": "<linear team id>"},
                    {"name": "assigneeId", "value": ""},
                    {"name": "labelId", "value": "<label id>"},
                    {"name": "projectId", "value": ""},
                    {"name": "stateId", "value": "<state id>"},
                    {"name": "priority", "value": "1"},
                ],
                "hasSchemaFormConfig": True,
            },
        ],
    },
)
print(response.json())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentry_api_python-0.3.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

sentry_api_python-0.3.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file sentry_api_python-0.3.0.tar.gz.

File metadata

  • Download URL: sentry_api_python-0.3.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.8.16 Linux/5.15.0-1033-azure

File hashes

Hashes for sentry_api_python-0.3.0.tar.gz
Algorithm Hash digest
SHA256 00cf028f2b2712d6779a0b84da91fef5fedf86b22ee5ce4f790e598d2c1f45a0
MD5 72cdefc1a6fd5b395446b186b212525e
BLAKE2b-256 b4c3b8ae8a2dab45490569c43e8fe0deef267c7f2112f48f0001875a7f0d48c5

See more details on using hashes here.

File details

Details for the file sentry_api_python-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sentry_api_python-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.8.16 Linux/5.15.0-1033-azure

File hashes

Hashes for sentry_api_python-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea38ed70eb915f8265205a5633f6b0a371aaee7e56e874a05294790b98a9c7d8
MD5 6ec8f31330c7ce310404773c605dd075
BLAKE2b-256 3c0e8a9b5b4362f7ab1c7f8a646a6f73dacbb7c51cbb7cc3a32976d919943d05

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page