Export Analytics with REST Endpoint

LangWatch offers you the possibility to build and integrate LangWatch graph’s on your own systems and applications, to display it to your customers in another interface.

On LangWatch dashboard, you can use our powerful custom chart builder tool, to plot any data collected and generated by LangWatch, and customize the way you want to display it. You can then use our REST API to fetch the graph data.

Usage: You will need to obtain your JSON payload from the custom graph section in our application. You can find this on the Analytics page > Custom Reports > Add chart.

  1. Pick the custom graph you want to get the analytics for.
  2. Prepare your JSON data. Make sure it’s is the same format that is showing in the LangWatch application.
  3. Use the curl command to get you analytics data. Here is a basic template:
# Set your API key and endpoint URL
API_KEY="your_langwatch_api_key"
ENDPOINT="https://app.langwatch.ai/api/analytics"

# Use curl to send the POST request, e.g.:
curl -X POST "$ENDPOINT" \
    -H "X-Auth-Token: $API_KEY" \
    -H "Content-Type: application/json" \
    -d @- <<EOF
    {
     "startDate": 1708434000000,
     "endDate": 1710939600000,
     "filters": {},
     "series": [
       {
         "metric": "metadata.user_id",
         "aggregation": "cardinality"
       }
     ],
     "timeScale": 1
   }
EOF
  1. Execute the curl command. If successful, LangWatch will return the custom analytics data in the response.

Screenshots on how to get the JSON data.

On the right menu button above the graph you will see the Show API menu link. Click that and a modal will then popup.

Within this modal, you’ll find the JSON payload required for the precise custom analytics data. Simply copy this payload and paste it into the body of your REST POST request.

Now you’re fully prepared to access your customized analytics and seamlessly integrate them into your specific use cases.

If you encounter any hurdles or have questions, our support team is eager to assist you.