TypeScript and JavaScript
Amberflo is the simplest way to integrate metering into your application.
This is the official TypeScript (and JavaScript) client that wraps the Amberflo REST API.
- Add and update customers
- Assign and update product plans to customers
- List invoices of a customer
- Get a new customer portal session for a customer
- Add and list prepaid orders to customers
- Send meter events in asynchronous batches for high throughput (with optional flush on demand)
- Query usage
- Install the SDK
3. Create a customer
4. Ingest meter events
5. Query usage
This library can also be used directly with JavaScript. For instance:
For instance, suppose you have the index.js bellow. You can run it with node index.js.
Amberflo.io libraries are built to support high throughput environments. That means you can safely send hundreds of meter records per second. For example, you can chose to deploy it on a web server that is serving hundreds of requests per second.
However, every call does not result in a HTTP request, but is queued in memory instead. Messages are batched and flushed in the background, allowing for much faster operation. The size of batch and rate of flush can be customized.
Automatic flush: When operating with auto flush mode, which is the default, the messages will accumulate in the queue until either the batch size is reached or some period of time elapses. When either happens, the batch is sent.
Flush on demand: For example, at the end of your program, you'll want to flush to make sure there's nothing left in the queue. Calling this method will block the calling thread until there are no messages left in the queue. So, you'll want to use it as part of your cleanup scripts and avoid using it as part of the request lifecycle.
General documentation on how to use Amberflo is available at Product Walktrough.
The full REST API documentation is available at API Reference .
Code samples covering different scenarios are available in the samples folder.
Ingest
Customer
Usage