npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vayu-billing/client

v0.0.10

Published

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

Downloads

35

Readme

Vayu API Client Library

Overview

The Vayu API client library in TypeScript allows you to submit events for processing and storage, manage billing-related entities, and perform various other operations seamlessly.

Installation

Install the Vayu API client library using npm:

npm install vayu-client

Usage

Initialization

Initialize the Vayu API client. The baseUrl parameter is optional and defaults to Vayu's public API servers.

import { VayuClient } from 'vayu-client';

const vayu = new VayuClient({
  accessToken: 'your-access-token',
  baseUrl: 'https://connect.withvayu.com'  // Optional
});

Authentication

Login and Obtain Access Token

To obtain a new access token, use the login method:

const response = await vayu.auth.login({
  refreshToken: 'your-refresh-token'
});

console.log(response.accessToken);

Events

Sending Events

To send a batch of events for processing and storage:

const events = [
  {
    name: 'api_call',  // The distinctive label assigned to an event
    timestamp: new Date().toISOString(),  // The exact moment of event occurrence in ISO 8601 format
    customerAlias: 'customer_12345',  // A unique identifier assigned to each customer
    ref: '4f6cf35x-2c4y-483z-a0a9-158621f77a21',  // A universally unique identifier for each event
    data: {
      key1: 'processing_duration',  // Example additional data
      key2: 'api_url'  // Example additional data
    }
  }
];

const response = await vayu.events.sendEvents({ events });

console.log(response.validEvents);
console.log(response.invalidEvents);

Querying Events

To fetch events occurring within a specified timestamp range:

const response = await vayu.events.queryEvents({
  startTime: '2023-09-01T00:00:00.000Z',
  endTime: '2023-09-30T23:59:59.999Z',
  eventName: 'api_call',
  limit: 10
});

console.log(response.events);

Getting Event by Ref ID

To get a specific event using its reference ID:

const response = await vayu.events.getEventByRefId('4f6cf35x-2c4y-483z-a0a9-158621f77a21');

console.log(response.event);

Deleting Event by Ref ID

To delete a specific event using its reference ID:

const response = await vayu.events.deleteEventByRefId('4f6cf35x-2c4y-483z-a0a9-158621f77a21');

console.log(response.event);

Customers

Creating a Customer

To create a new customer:

const response = await vayu.customers.createCustomer({
  name: 'John Doe',
  alias: 'customer_12345'
});

console.log(response.customer);

Updating a Customer

To update an existing customer by ID:

const response = await vayu.customers.updateCustomer('customer-id', {
  name: 'Jane Doe',
  alias: 'customer_67890'
});

console.log(response.customer);

Deleting a Customer

To delete a customer by ID:

const response = await vayu.customers.deleteCustomer('customer-id');

console.log(response.customer);

Meters

Meters are entities that track and aggregate usage data based on events. They are crucial for billing and monitoring purposes.

Listing Meters

To get a list of meters:

const response = await vayu.meters.listMeters({
  limit: 10,
  cursor: 'next-cursor'
});

console.log(response.meters);
console.log(response.total);
console.log(response.hasMore);
console.log(response.nextCursor);

Features

The Vayu API client library provides access to the following features:

  • Auth
    • auth.login()
  • Events
    • events.sendEvents()
    • events.queryEvents()
    • events.getEventByRefId()
    • events.deleteEventByRefId()
    • events.sendEventsDryRun()
  • Customers
    • customers.createCustomer()
    • customers.updateCustomer()
    • customers.deleteCustomer()
    • customers.listCustomers()
    • customers.getCustomer()
  • Meters
    • meters.getMeter()
    • meters.updateMeter()
    • meters.deleteMeter()
    • meters.listMeters()
  • Plans
    • plans.getPlan()
    • plans.deletePlan()
    • plans.listPlans()
  • Contracts
    • contracts.createContract()
    • contracts.deleteContract()
    • contracts.listContracts()
    • contracts.getContract()
  • Invoices
    • invoices.getInvoice()
    • invoices.listInvoices()

Support

If you have any questions or need further assistance, please contact Vayu at [email protected].

License

This project is licensed under the MIT License.


This README provides an overview and usage examples for the Vayu API client library. For more detailed information on each method, please refer to the official Vayu API documentation.