Simple and easy to use python package for utilizing vayu billing system
Project description
Vayu Client Usage Example
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
# Initialize vayu
vayu = Vayu('YOUR_ACCESS_KEY')
# Create and send the event
vayu.send_events([{
'name': 'api_call',
'timestamp': datetime.now(),
'customerAlias': 'customer_12345',
'data': {
'key1': 'processing_duration',
'key2': 'api_url'
},
'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': {
'key1': 'processing_duration',
'key2': 'api_url'
},
'ref': '4f6cf35x-2c4y-483z-a0a9-158621f77a21'
}])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for vayu_client-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 480f56b7b0003fe7d973bb098e106800b3ded82d1adfdc5511dbdb5423b71dbc |
|
MD5 | 788ecc2dd5b9c24bf1be521927fcfef6 |
|
BLAKE2b-256 | be9efb72e6c297d459a9cac0a7ac60e8981a7f186f4a2f123ef7ee2162807676 |