Skip to main content

Visualization

The easiest way to use the Visualization API is to use the "Export as Visualize API Call" button in the visualizer tool. However you can find the official documentation below.

API Endpoint

https://www.graphjson.com/api/visualize/iframe

API Parameters

FieldTypeDescription
api_keystringyour account api key
collectionstringthe collection you want to query data from
IANA_time_zonestringthe time zone you want result dates formatted in
graph_typestringthe type of graph you want data for
startstringwhere you want the query to begin
endstringwhere you want the query to end
filtersarraylist of filters to filter down the query
metricstringwhat metric you want to aggregate on
aggregationstringthe type of aggregation you want to do
customizationsobjectvarious visual customizations for graphs
granularitystringthe granularity of the data returned
comparestringthe time period you want to compare against

So for instance, in Python your code might look like

import requests
import json
import time

payload = {
"api_key": os.getenv('GRAPHJSON_API_KEY'),
"collection": "all_events",
"IANA_time_zone": "America/Los_Angeles",
"graph_type": "Single Line",
"start": "7 days ago",
"end": "now",
"filters": [],
"metric": None,
"aggregation": "Count",
"compare": "7 days ago",
"granularity": "auto",
"customizations": {"showYAxis":true,"showDots":true,"lineColor":"#987DE3","secondaryColor":"#9CA3AF"}
}

r = requests.post("https://www.graphjson.com/api/visualize/iframe", json=payload)
html = f'<iframe src="{r.json()["url"]}" />'