Create an API-based Chart

Create an API-based Chart

Creating an API-based Chart

Sometimes, charts data are complicated and closely tied to your business. Forest Admin allows you to code how the chart is computed. Choose API as the data source when configuring your chart.

Forest Admin will make the HTTP call to Smart Chart URL when retrieving the chart values for the rendering.

Value API-based Chart

On our Live Demo, we have a MRR value chart which computes our Monthly Recurring Revenue. This chart queries the Stripe API to get all charges made in the current month (in March for this example).

When serializing the data, we use the Liana.StatSerializer() serializer. Check the value syntax below.

Repartition API-based Chart

On our Live Demo, we have a Charges repartition chart which shows a repartition chart distributed by credit card country. This chart queries the Stripe API to get all charges made in the current month (in March for this example) and check the credit card country.

When serializing the data, we use the Liana.StatSerializer() serializer. Check the value syntax below.

Time-based API-based Chart

On our Live Demo, we have a Charges time-based chart which shows the number of charges per day. This chart queries the Stripe API to get all charges made in the current month (in March for this example) and group data by day.

When serializing the data, we use the Liana.StatSerializer() serializer. Check the value syntax below.

Objective API-based Chart

Creating an Objective Smart Chart means you'll be fetching your data from an external API endpoint:

This endpoint must return data with the following format:

Here's how you could implement it:

Last updated

Was this helpful?