Skip to main content

Simple and easy to use python package for utilizing vayu billing system

Project description

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:

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.

from vayu import Vayu

Step 2: Initialize the Client

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

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:

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'
}])

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

vayu_client-1.0.5.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vayu_client-1.0.5-py3-none-any.whl (141.9 kB view details)

Uploaded Python 3

File details

Details for the file vayu_client-1.0.5.tar.gz.

File metadata

  • Download URL: vayu_client-1.0.5.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for vayu_client-1.0.5.tar.gz
Algorithm Hash digest
SHA256 b81dbdbaac1d57c58b958b7b33a1f9908fd07057c40092c358cb18b8b4ea01f7
MD5 84092e3c7d23aead8f54ab46a6e23009
BLAKE2b-256 706b9b76d640ad2bb51293fc7149095e5049cf89dbcbd5d5cdf5b2a0c0588b4b

See more details on using hashes here.

File details

Details for the file vayu_client-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: vayu_client-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 141.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for vayu_client-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 32a6dfa7ee43249fd9029bf81141cb28d44f9dd0b05e9098f26c83e8e1b568f9
MD5 c0abfc1b37e493a7077d0c4406273c60
BLAKE2b-256 5d5a4a41ceab042467a9e4282c5fdbf0e8459aa7b9d1c5bd6a144d8ab3e8f9c2

See more details on using hashes here.

Supported by

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