Quick Start

Get up and running with Kable in under 15 minutes

This Quick Start guide will walk you through the steps to begin building with Kable. By the end of this tutorial you will have everything you need to launch your API product with Kable.

For this tutorial, let's consider the sample use case of a messaging API called Mailman.

Estimated completion: 15 minutes

📘

If after working through the Quick Start guide below you'd like to schedule an onboarding session with someone from Kable, feel free to reach out and we'll get in touch.

Sign up for Kable

First, create a free account on Kable. You can sign up here.

Create a dimension

Dimensions are metrics that are meaningful to your business. Define a new metric from the Dimensions tab in your dashboard.

As an example, Mailman might create a "Text Message" dimension with a key of messageId. You can learn more about dimensions here.

Create a plan

Plans define pricing and control how customers are billed each month. Create a plan from the Plans tab in your dashboard.

Let's say Mailman wanted to charge $0.10 per text message. Mailman might set up a plan based on the count of text messages per month, with unit pricing of $0.10 each.

For more complex pricing scenarios, check out the plans section of the docs.

Create a customer

Customers are the developers, applications, or businesses who consume your API. You can create customers from the Customers tab in your dashboard or programmatically through the API.

The Client ID (clientId) you set on each customer should correspond to some unique identifier in your application. You'll use this identifier later when recording usage events in Kable.

While you're here, you may also add the pricing plan you created in the last step to your new customer. (This can also be done programmatically through the API.)

Integrate your application

Download an SDK

First, download the Kable SDK for your programming language of choice. If we do not yet support a library in your language, you can integrate directly with the API.

📘

If we do not yet support a library for your language, please let us know.

Configure Kable in your API

To configure the library (or use the API) you'll need API keys. Generate a Test Environment Key from the Company tab in your dashboard. Treat API keys like passwords -- store them somewhere secure and do not share them with anyone.

A properly-configured Kable instance may look something like:

const { Kable } = require('kable-node-express');

const kable = new Kable({
  kableClientId: '<YOUR_KABLE_CLIENT_ID>',
  kableClientSecret: '<YOUR_KABLE_CLIENT_SECRET>',
  baseUrl: 'https://test.kable.io',
  debug: true
});
from kable_python_flask import Kable

kable = Kable({
  'kable_client_id': '<YOUR_KABLE_CLIENT_ID>',
  'kable_client_secret': '<YOUR_KABLE_CLIENT_SECRET>',
  'base_url': 'https://test.kable.io',
  'debug': True
})

Record Metrics

Finally, we'll record some metrics from your API. We'll use kable.record (or the API directly) to ingest usage events into Kable.

Include the clientId you defined for your customer as well as any dimension metrics you might want to track in the payload of the request. As an example, Mailman's API might look something like:

app.post('/api/messages/send', function(req, res) {
  kable.record({ 
    clientId: 'yourcompanyuser_1234567890', 
    messageId: 'msg_ABC123XYZ456'
  });
  // ...
  res.json({ message: 'Message sent!' });
});
@app.post('/api/messages/send')
def send_message_api():
    kable.record({ 
      "clientId": "yourcompanyuser_1234567890", 
      "messageId": "msg_ABC123XYZ456"
    })
    # ...
    return jsonify({ 'message': 'Message sent!' })

Next steps

That's it, you're done! If you jump back into your dashboard you'll see usage metrics flowing into Kable as your API is used.

Looking ahead, you may want to define additional metrics, create additional pricing plans, or enhance your integration with Kable by programmatically creating customers and recording additional metrics. You may also want to Connect with Stripe to enable automatic invoicing of your customers.

Once you've tested your integration in the Test environment you're ready to generate Live keys and deploy to production!

📘

Kable as an Authentication Provider

Some customers choose to use Kable to authenticate their API in addition to tracking usage metrics and managing pricing and invoicing. For an overview of how to set up Kable as an authentication provider, see the Kable for API Authentication section.

We're always searching for ways to improve our documentation and help our customers. If you have any thoughts about how we can improve or how Kable can help you scale your business, please let us know!


Did this page help you?