Sending Data to Revenium's Metering API
While Revenium offers a number of pre-built connectors and SDKs, you can also send data directly with our metering API, which is explained below.
This tutorial will guide you through the process of sending data to Revenium's Metering API using curl. We'll cover the main endpoints and provide examples for each. Finally, here is a link to complete API documentation.
Prerequisites
curl installed on your system
Your Revenium API key
Authentication
All requests to the Revenium Metering API require authentication using an API key. Include your API key in the x-api-key
header with each request.
The terms in this document map to the v1 Revenium API, which don't always match with the terms used in the user interface. The forthcoming v2 API will map to Revenium's current lexicon. (full details)
Submitting API Metering Data
To submit API metering data, use the /meter
endpoint.
The /meter
endpoint is designed for the submission of API-specific monetization and analytics data to Revenium. It is typically used to send data after an API response is received. The data submitted to this endpoint encapsulates the metadata for a single API transaction, providing important details for monetization and observability purposes.
Replace YOUR_API_KEY
with your actual Revenium API key.
Saving an API Event
To save an API event, use the /event
endpoint.
The /event
endpoint is similar to the /meter
endpoint but is used to submit API requests and responses separately. Revenium will then correlate these requests and responses into a single API transaction that mirrors a request to the /meter
endpoint. This endpoint is particularly useful for integrating with asynchronous or stateless API event data, such as from cloud gateways or logging systems.
Submitting an API Request Event
Submitting an API Request Response
Submitting Rating Events
To submit rating events, use the /meter/rate
endpoint.
Compared to the metering endpoint, rating events do not contain analytics data, but allow for a simpler integration if you are only interested in counting & rating events from your application in Revenium. Rating Events are useful for metering and monetizing non-API centric data from sources like iPaaS applications, legacy billing systems, or Lambda functions.
Ingesting Raw JSON Metering Data
To ingest raw JSON metering data, use the /meter/ingest
endpoint.
Raw JSON metering is useful when the structure of the metering data is unknown in advance. Revenium will attempt to extract key/value pairs from the JSON payloads, which can then be configured as Metering Elements for monetization.
Validating a Subscription and Subscriber Credential
To check if a subscription or subscription credential is valid, use the /meter/product-key
endpoint.
Checking if a Subscription is Valid
Checking if a Subscription Credential is Valid
Replace YOUR_SUBSCRIPTION_KEY
and YOUR_SUBSCRIPTION_CREDENTIAL with the actual values you want to validate.
You can find the subscription key using the 'key' field when viewing a subscription in the Revenium user interface. The value to use for your subscriber credential is the 'external ID' found in the Revenium UI when viewing a subscriber credential.
In either scenario the endpoint will return a 200 status code along with a JWT claim containing metadata about the subscription:
If the subscription is invalid then a 404 response code will be returned.
Error Handling
If you encounter any errors, check the response body for error messages and details. Common HTTP status codes you might encounter include:
200: Successful request
400: Bad request (check your input data)
403: Unauthorized (check your API key)
Always ensure you're using the latest version of the API and refer to the official Revenium documentation for any updates or changes to the API endpoints and parameters.
Last updated