Git Product home page Git Product logo

python-client's Introduction

Apitally logo

API monitoring made easy.

Apitally is a simple API monitoring & analytics tool with a focus on data privacy.
It is super easy to use for API projects in Python or Node.js and never collects sensitive data.

๐Ÿ”— apitally.io

Apitally screenshots


Apitally client library for Python

Tests Codecov PyPI

This client library for Apitally currently supports the following Python web frameworks:

Learn more about Apitally on our ๐ŸŒŽ website or check out the ๐Ÿ“š documentation.

Key features

  • Middleware for different frameworks to capture metadata about API endpoints, requests and responses (no sensitive data is captured)
  • Non-blocking clients that aggregate and send captured data to Apitally in regular intervals

Install

Use pip to install and provide your framework of choice as an extra, for example:

pip install apitally[fastapi]

The available extras are: fastapi, flask, django_rest_framework, django_ninja, starlette and litestar.

Usage

Our setup guides include all the details you need to get started.

FastAPI

This is an example of how to add the Apitally middleware to a FastAPI application. For further instructions, see our setup guide for FastAPI.

from fastapi import FastAPI
from apitally.fastapi import ApitallyMiddleware

app = FastAPI()
app.add_middleware(
    ApitallyMiddleware,
    client_id="your-client-id",
    env="dev",  # or "prod" etc.
)

Flask

This is an example of how to add the Apitally middleware to a Flask application. For further instructions, see our setup guide for Flask.

from flask import Flask
from apitally.flask import ApitallyMiddleware

app = Flask(__name__)
app.wsgi_app = ApitallyMiddleware(
    app,
    client_id="your-client-id",
    env="dev",  # or "prod" etc.
)

Django

This is an example of how to add the Apitally middleware to a Django Ninja or Django REST Framework application. For further instructions, see our setup guide for Django.

In your Django settings.py file:

MIDDLEWARE = [
    "apitally.django.ApitallyMiddleware",
    # Other middleware ...
]
APITALLY_MIDDLEWARE = {
    "client_id": "your-client-id",
    "env": "dev",  # or "prod" etc.
}

Litestar

This is an example of how to add the Apitally plugin to a Litestar application. For further instructions, see our setup guide for Litestar.

from litestar import Litestar
from apitally.litestar import ApitallyPlugin

app = Litestar(
    route_handlers=[...],
    plugins=[
        ApitallyPlugin(
            client_id="your-client-id",
            env="dev",  # or "prod" etc.
        ),
    ]
)

Getting help

If you need help please create a new discussion on GitHub or join our Slack workspace.

License

This library is licensed under the terms of the MIT license.

python-client's People

Contributors

itssimon avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

python-client's Issues

Error trying to get request size using django middleware

Hi guys, english isn't my first language, so please excuse any mistakes.

I'm trying to use the last version of django middleware (0.6.1) i have the next error:

invalid literal for int() with base 10: ''
Request Method: GET
Request URL: http://localhost:8001/api/job/
Django Version: 5.0.3
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: ''
Exception Location: /usr/local/lib/python3.10/site-packages/apitally/client/base.py, line 135, in add_request
Raised during: job.views.JobList
Python Executable: /usr/local/bin/python
Python Version: 3.10.13
Python Path:
['/app',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'/usr/local/lib/python3.10/site-packages']

It looks like that when you are trying to get the size of a request ( request.headers.get("Content-Length")) and the result is '' (an empty string) it impossible to make the convertion to an integer object in line 135 of /apitally/client/base.py file and there is not validation for an empty string in line 134 of /apitally/client/base.py file.

Right now, the only option i have is using the 0.3.4 of the library.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update dependency ruff to v0.5.5
  • Update pre-commit hook charliermarsh/ruff-pre-commit to v0.5.5
  • Update dependency sentry-sdk to v2.11.0
  • Update dependency starlette to v0.38.1

Pending Branch Automerge

These updates await pending status checks before automerging. Click on a checkbox to abort the branch automerge, and create a PR instead.

  • Lock file maintenance

Detected dependencies

github-actions
.github/workflows/publish.yaml
  • actions/checkout v4
  • snok/install-poetry v1
.github/workflows/summary.yaml
  • poseidon/wait-for-status-checks v0.5.0
.github/workflows/tests.yaml
  • actions/checkout v4
  • actions/setup-python v5
  • pre-commit/action v3.0.1
  • actions/checkout v4
  • actions/cache v4
  • snok/install-poetry v1
  • actions/setup-python v5
  • codecov/codecov-action v4
  • actions/checkout v4
  • actions/cache v4
  • snok/install-poetry v1
  • actions/setup-python v5
pep621
pyproject.toml
poetry
pyproject.toml
  • backoff >=2.0.0
  • python >=3.8,<4.0
  • django-ninja >=0.18.0
  • djangorestframework >=3.10.0
  • fastapi >=0.87.0
  • flask >=2.0.0
  • httpx >=0.22.0
  • inflection >=0.5.1
  • litestar >=2.0.0
  • requests >=2.26.0
  • sentry-sdk >=2.2.0
  • starlette >=0.21.0,<1.0.0
  • uritemplate >=3.0.0
  • ipykernel ^6.26.0
  • mypy ^1.10.0
  • ruff ^0.5.0
  • pytest-cov ^5.0.0
  • pytest-mock ^3.12.0
  • requests-mock ^1.11.0
  • django-types *
  • djangorestframework-types *
pre-commit
.pre-commit-config.yaml
  • pre-commit/pre-commit-hooks v4.6.0
  • charliermarsh/ruff-pre-commit v0.5.3
  • python-poetry/poetry 1.8.3

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.