vayu-client


Namevayu-client JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://withvayu.com
SummarySimple and easy to use python package for utilizing vayu billing system
upload_time2024-01-25 09:51:56
maintainer
docs_urlNone
authorVayu, Inc.
requires_python==3.7.*
license
keywords vayu billing events python sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Vayu python client

## Prerequisites

- Python 3.7 and above
- Install the `vayu-client` package (`pip install vayu-client`)

## End-to-End Code Example

To illustrate how to use the `Vayu` library for sending events to Vayu's API, here is a complete code snippet. This example combines all the steps detailed in previous sections:

```python
from datetime import datetime
from vayu import Vayu

vayu = Vayu('YOUR_ACCESS_KEY')

vayu.send_events([{
    'name': 'api_call',
    'timestamp': datetime.now(),
    'customerAlias': 'customer_12345',
    'data': {
        'processing_duration': 124.83,
        'api_endpoint': '/api/v1/users',
    },
    'ref': '4f6cf35x-2c4y-483z-a0a9-158621f77a21'
}])
```

That's it! This example demonstrates how to send an event using Python and the `Vayu` library.

## Step-by-step Guide

### Step 1: Import Vayu

The first step is to import the `Vayu` class from the `Vayu` package.

```python
from vayu import Vayu
```

### Step 2: Initialize the Client

After importing, create a new `Vayu` instance and pass the api key

```python
vayu = Vayu('YOUR_API_KEY')
```

### Step 3: Send Events

Finally, you can send events to the Vayu API by using the `send_events` method. The method takes a list of dictionaries, where each dictionary represents a single event. Each event dictionary should contain the following fields:

- `name` (string - required): A distinctive label assigned to an event. It serves as a critical identifier for categorizing and pricing events.
- `timestamp` (datetime): The exact moment when the event occurs.
- `customerAlias` (string): A unique identifier for each customer, which may be pseudonymous or obfuscated.
- `data` (object): A schema-less JSON object containing miscellaneous attributes and metrics associated with the event.
- `ref` (string, optional): A UUID or other high-entropy string serving as an immutable reference for each event entry.

Example:

```python
vayu.send_events([{
    'name': 'api_call',
    'timestamp': datetime.now(),
    'customerAlias': 'customer_12345',
    'data': {
        'processing_duration': 124.83,
        'api_endpoint': '/api/v1/users',
    },
    'ref': '4f6cf35x-2c4y-483z-a0a9-158621f77a21'
}])
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://withvayu.com",
    "name": "vayu-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "==3.7.*",
    "maintainer_email": "",
    "keywords": "vayu,billing,events,python,sdk",
    "author": "Vayu, Inc.",
    "author_email": "team@withvayu.com",
    "download_url": "https://files.pythonhosted.org/packages/80/8c/d8c3d5edfe8ae4ff5caf611d052d7414b04a3817b2f83b6b21d3f27f14b8/vayu_client-1.0.2.tar.gz",
    "platform": null,
    "description": "# Vayu python client\n\n## Prerequisites\n\n- Python 3.7 and above\n- Install the `vayu-client` package (`pip install vayu-client`)\n\n## End-to-End Code Example\n\nTo illustrate how to use the `Vayu` library for sending events to Vayu's API, here is a complete code snippet. This example combines all the steps detailed in previous sections:\n\n```python\nfrom datetime import datetime\nfrom vayu import Vayu\n\nvayu = Vayu('YOUR_ACCESS_KEY')\n\nvayu.send_events([{\n    'name': 'api_call',\n    'timestamp': datetime.now(),\n    'customerAlias': 'customer_12345',\n    'data': {\n        'processing_duration': 124.83,\n        'api_endpoint': '/api/v1/users',\n    },\n    'ref': '4f6cf35x-2c4y-483z-a0a9-158621f77a21'\n}])\n```\n\nThat's it! This example demonstrates how to send an event using Python and the `Vayu` library.\n\n## Step-by-step Guide\n\n### Step 1: Import Vayu\n\nThe first step is to import the `Vayu` class from the `Vayu` package.\n\n```python\nfrom vayu import Vayu\n```\n\n### Step 2: Initialize the Client\n\nAfter importing, create a new `Vayu` instance and pass the api key\n\n```python\nvayu = Vayu('YOUR_API_KEY')\n```\n\n### Step 3: Send Events\n\nFinally, you can send events to the Vayu API by using the `send_events` method. The method takes a list of dictionaries, where each dictionary represents a single event. Each event dictionary should contain the following fields:\n\n- `name` (string - required): A distinctive label assigned to an event. It serves as a critical identifier for categorizing and pricing events.\n- `timestamp` (datetime): The exact moment when the event occurs.\n- `customerAlias` (string): A unique identifier for each customer, which may be pseudonymous or obfuscated.\n- `data` (object): A schema-less JSON object containing miscellaneous attributes and metrics associated with the event.\n- `ref` (string, optional): A UUID or other high-entropy string serving as an immutable reference for each event entry.\n\nExample:\n\n```python\nvayu.send_events([{\n    'name': 'api_call',\n    'timestamp': datetime.now(),\n    'customerAlias': 'customer_12345',\n    'data': {\n        'processing_duration': 124.83,\n        'api_endpoint': '/api/v1/users',\n    },\n    'ref': '4f6cf35x-2c4y-483z-a0a9-158621f77a21'\n}])\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple and easy to use python package for utilizing vayu billing system",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://withvayu.com"
    },
    "split_keywords": [
        "vayu",
        "billing",
        "events",
        "python",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11a6db4d06b4e0a9174119c39ba104438625e632aa42709a633bf19efb404742",
                "md5": "db6a1b39972e09fb6c7d7d5de866bb07",
                "sha256": "97f00dbb4657921a26e3c8973487747f243dab66577851c8bc3680b224b7980a"
            },
            "downloads": -1,
            "filename": "vayu_client-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db6a1b39972e09fb6c7d7d5de866bb07",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "==3.7.*",
            "size": 29881,
            "upload_time": "2024-01-25T09:51:55",
            "upload_time_iso_8601": "2024-01-25T09:51:55.030747Z",
            "url": "https://files.pythonhosted.org/packages/11/a6/db4d06b4e0a9174119c39ba104438625e632aa42709a633bf19efb404742/vayu_client-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "808cd8c3d5edfe8ae4ff5caf611d052d7414b04a3817b2f83b6b21d3f27f14b8",
                "md5": "13d414bef73bcee1aa149c16447b77b0",
                "sha256": "8e8ca378c5f861ff8b0fad39493c3e15d92fb4a231483e141fb3f5f65325bee0"
            },
            "downloads": -1,
            "filename": "vayu_client-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "13d414bef73bcee1aa149c16447b77b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "==3.7.*",
            "size": 20185,
            "upload_time": "2024-01-25T09:51:56",
            "upload_time_iso_8601": "2024-01-25T09:51:56.807469Z",
            "url": "https://files.pythonhosted.org/packages/80/8c/d8c3d5edfe8ae4ff5caf611d052d7414b04a3817b2f83b6b21d3f27f14b8/vayu_client-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-25 09:51:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "vayu-client"
}
        
Elapsed time: 0.26003s