moesifpythonrequest


Namemoesifpythonrequest JSON
Version 0.3.3 PyPI version JSON
download
home_pagehttps://www.moesif.com/docs
SummaryMoesif Python request
upload_time2024-01-11 01:51:04
maintainer
docs_urlNone
authorMoesif, Inc
requires_python
licenseApache Software License
keywords moesif python request monkey patch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Moesif Python Requests

[![Built For][ico-built-for]][link-built-for]
[![Latest Version][ico-version]][link-package]
[![Language Versions][ico-language]][link-language]
[![Software License][ico-license]][link-license]
[![Source Code][ico-source]][link-source]

Interceptor for Python Requests lib to capture _outgoing_ API calls and sends to [Moesif](https://www.moesif.com) for API analytics and monitoring.

_If you are using Moesif's API monitoring SDKs like [Moesif Django](https://github.com/Moesif/moesifdjango) or [Moesif WSGI](https://github.com/moesif/moesifwsgi) to log incoming API calls, this library is already included._

## How to install

```shell
pip install moesifpythonrequest
```

Import the Moesif lib and call start_capture_outgoing.
Moesif will start logging all API calls made from the requests lib.

```python
from moesifpythonrequest.start_capture.start_capture import StartCapture
import requests

moesif_settings = {
    'APPLICATION_ID': 'Your Moesif Application Id'
}

def main():
    # Outgoing API call to third party like Github / Stripe or to your own dependencies
    response = requests.get("http://httpbin.org/uuid")
    print(response.json())

StartCapture().start_capture_outgoing(moesif_settings)
main()
```

Your Moesif Application Id can be found in the [_Moesif Portal_](https://www.moesif.com/).
After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.

## Configuration options

### __`APPLICATION_ID`__

(required) _string_, Your Moesif Application Id which can be found by logging
into the [_Moesif Portal_](https://www.moesif.com/), click on the top right menu,
and then clicking _Installation_.

### __`GET_METADATA_OUTGOING`__

(optional) _(req, res) => dictionary_, a function that enables you to return custom metadata associated with the logged API calls.
Takes in the [Requests](http://docs.python-requests.org/en/master/api/) request and response object as arguments. You should implement a function that
returns a dictionary containing your custom metadata. (must be able to be encoded into JSON). For example, you may want to save a VM instance_id, a trace_id, or a resource_id with the request.

### __`IDENTIFY_USER_OUTGOING`__

(optional, but highly recommended) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the user id used by your system. While Moesif tries to identify users automatically,
but different frameworks and your implementation might be very different, it would be helpful and much more accurate to provide this function.

### __`IDENTIFY_COMPANY_OUTGOING`__

(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the company id for this event.

### __`GET_SESSION_TOKEN_OUTGOING`__

(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the session token for this event. Again, Moesif tries to get the session token automatically, but if you setup is very different from standard, this function will be very help for tying events together, and help you replay the events.

### __`LOG_BODY_OUTGOING`__

(optional) _boolean_, default True, Set to False to remove logging request and response body.

### __`SKIP_OUTGOING`__

(optional) _(req, res) => boolean_, a function that takes a [Requests](http://docs.python-requests.org/en/master/api/) request and response,
and returns true if you want to skip this particular event.

### __`MASK_EVENT_MODEL`__

(optional) _(EventModel) => EventModel_, a function that takes a [Moesif EventModel](https://github.com/Moesif/moesifapi-python/blob/master/moesifapi/models/event_model.py) and returns an EventModel with desired data removed. For details regarding EventModel please see the [Moesif Python API Documentation](https://www.moesif.com/docs/api?python).

## Example

An example Moesif integration is [available on GitHub](https://github.com/Moesif/moesif-python-outgoing-example)

## Other integrations

To view more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).__

[ico-built-for]: https://img.shields.io/badge/built%20for-python%20requests-blue.svg
[ico-version]: https://img.shields.io/pypi/v/moesifpythonrequest.svg
[ico-language]: https://img.shields.io/pypi/pyversions/moesifpythonrequest.svg
[ico-license]: https://img.shields.io/badge/License-Apache%202.0-green.svg
[ico-source]: https://img.shields.io/github/last-commit/moesif/moesifpythonrequest.svg?style=social

[link-built-for]: http://docs.python-requests.org/en/master/
[link-package]: https://pypi.python.org/pypi/moesifpythonrequest
[link-language]: https://pypi.python.org/pypi/moesifpythonrequest
[link-license]: https://raw.githubusercontent.com/Moesif/moesifpythonrequest/master/LICENSE
[link-source]: https://github.com/Moesif/moesifpythonrequest

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.moesif.com/docs",
    "name": "moesifpythonrequest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "moesif python request monkey patch",
    "author": "Moesif, Inc",
    "author_email": "keyur@moesif.com",
    "download_url": "https://files.pythonhosted.org/packages/76/f4/05d836132940f94adf378dad09fed2bd2848b62d5a9f1d578ef918e5995d/moesifpythonrequest-0.3.3.tar.gz",
    "platform": null,
    "description": "# Moesif Python Requests\n\n[![Built For][ico-built-for]][link-built-for]\n[![Latest Version][ico-version]][link-package]\n[![Language Versions][ico-language]][link-language]\n[![Software License][ico-license]][link-license]\n[![Source Code][ico-source]][link-source]\n\nInterceptor for Python Requests lib to capture _outgoing_ API calls and sends to [Moesif](https://www.moesif.com) for API analytics and monitoring.\n\n_If you are using Moesif's API monitoring SDKs like [Moesif Django](https://github.com/Moesif/moesifdjango) or [Moesif WSGI](https://github.com/moesif/moesifwsgi) to log incoming API calls, this library is already included._\n\n## How to install\n\n```shell\npip install moesifpythonrequest\n```\n\nImport the Moesif lib and call start_capture_outgoing.\nMoesif will start logging all API calls made from the requests lib.\n\n```python\nfrom moesifpythonrequest.start_capture.start_capture import StartCapture\nimport requests\n\nmoesif_settings = {\n    'APPLICATION_ID': 'Your Moesif Application Id'\n}\n\ndef main():\n    # Outgoing API call to third party like Github / Stripe or to your own dependencies\n    response = requests.get(\"http://httpbin.org/uuid\")\n    print(response.json())\n\nStartCapture().start_capture_outgoing(moesif_settings)\nmain()\n```\n\nYour Moesif Application Id can be found in the [_Moesif Portal_](https://www.moesif.com/).\nAfter signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.\n\n## Configuration options\n\n### __`APPLICATION_ID`__\n\n(required) _string_, Your Moesif Application Id which can be found by logging\ninto the [_Moesif Portal_](https://www.moesif.com/), click on the top right menu,\nand then clicking _Installation_.\n\n### __`GET_METADATA_OUTGOING`__\n\n(optional) _(req, res) => dictionary_, a function that enables you to return custom metadata associated with the logged API calls.\nTakes in the [Requests](http://docs.python-requests.org/en/master/api/) request and response object as arguments. You should implement a function that\nreturns a dictionary containing your custom metadata. (must be able to be encoded into JSON). For example, you may want to save a VM instance_id, a trace_id, or a resource_id with the request.\n\n### __`IDENTIFY_USER_OUTGOING`__\n\n(optional, but highly recommended) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the user id used by your system. While Moesif tries to identify users automatically,\nbut different frameworks and your implementation might be very different, it would be helpful and much more accurate to provide this function.\n\n### __`IDENTIFY_COMPANY_OUTGOING`__\n\n(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the company id for this event.\n\n### __`GET_SESSION_TOKEN_OUTGOING`__\n\n(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the session token for this event. Again, Moesif tries to get the session token automatically, but if you setup is very different from standard, this function will be very help for tying events together, and help you replay the events.\n\n### __`LOG_BODY_OUTGOING`__\n\n(optional) _boolean_, default True, Set to False to remove logging request and response body.\n\n### __`SKIP_OUTGOING`__\n\n(optional) _(req, res) => boolean_, a function that takes a [Requests](http://docs.python-requests.org/en/master/api/) request and response,\nand returns true if you want to skip this particular event.\n\n### __`MASK_EVENT_MODEL`__\n\n(optional) _(EventModel) => EventModel_, a function that takes a [Moesif EventModel](https://github.com/Moesif/moesifapi-python/blob/master/moesifapi/models/event_model.py) and returns an EventModel with desired data removed. For details regarding EventModel please see the [Moesif Python API Documentation](https://www.moesif.com/docs/api?python).\n\n## Example\n\nAn example Moesif integration is [available on GitHub](https://github.com/Moesif/moesif-python-outgoing-example)\n\n## Other integrations\n\nTo view more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).__\n\n[ico-built-for]: https://img.shields.io/badge/built%20for-python%20requests-blue.svg\n[ico-version]: https://img.shields.io/pypi/v/moesifpythonrequest.svg\n[ico-language]: https://img.shields.io/pypi/pyversions/moesifpythonrequest.svg\n[ico-license]: https://img.shields.io/badge/License-Apache%202.0-green.svg\n[ico-source]: https://img.shields.io/github/last-commit/moesif/moesifpythonrequest.svg?style=social\n\n[link-built-for]: http://docs.python-requests.org/en/master/\n[link-package]: https://pypi.python.org/pypi/moesifpythonrequest\n[link-language]: https://pypi.python.org/pypi/moesifpythonrequest\n[link-license]: https://raw.githubusercontent.com/Moesif/moesifpythonrequest/master/LICENSE\n[link-source]: https://github.com/Moesif/moesifpythonrequest\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "Moesif Python request",
    "version": "0.3.3",
    "project_urls": {
        "Homepage": "https://www.moesif.com/docs"
    },
    "split_keywords": [
        "moesif",
        "python",
        "request",
        "monkey",
        "patch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f3c451d5641c88a53cd10089a7a618a919d11ff7d7331a8aa928e957f172172",
                "md5": "3af61cc2a0b5675946d5836e62d6bed9",
                "sha256": "66603fb2b5e6c0c8647950b383075db134c660e0a3623b337a12a4a480adddc5"
            },
            "downloads": -1,
            "filename": "moesifpythonrequest-0.3.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3af61cc2a0b5675946d5836e62d6bed9",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 17800,
            "upload_time": "2024-01-11T01:51:02",
            "upload_time_iso_8601": "2024-01-11T01:51:02.379965Z",
            "url": "https://files.pythonhosted.org/packages/7f/3c/451d5641c88a53cd10089a7a618a919d11ff7d7331a8aa928e957f172172/moesifpythonrequest-0.3.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76f405d836132940f94adf378dad09fed2bd2848b62d5a9f1d578ef918e5995d",
                "md5": "8eded2284d4e0d0ec20c0c85da45be1c",
                "sha256": "12a4a8063224ea13510c3c3074ba2497ddc0d1ab2dced7c6d8ee2253f3cb0f29"
            },
            "downloads": -1,
            "filename": "moesifpythonrequest-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "8eded2284d4e0d0ec20c0c85da45be1c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17086,
            "upload_time": "2024-01-11T01:51:04",
            "upload_time_iso_8601": "2024-01-11T01:51:04.335470Z",
            "url": "https://files.pythonhosted.org/packages/76/f4/05d836132940f94adf378dad09fed2bd2848b62d5a9f1d578ef918e5995d/moesifpythonrequest-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-11 01:51:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "moesifpythonrequest"
}
        
Elapsed time: 0.16143s