Logging
The easiest way to log data is to use the auto generated logging code in the visualizer logging tab. However you can find the official documentation below.
API Endpoint
https://api.graphjson.com/api/log
API Parameters
Field | Type | Description |
---|---|---|
api_key | string | your account api key |
collection | string | the collection you want to query data from |
timestamp | number | the unix timestamp of the event |
json | string | the json event you want to log |
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",
"timestamp": int(time.time()),
"json": json.dumps({
"Event": "Uber Ride",
"Price": 9.99,
"Driver_Rating": 5,
"Driver_ID": "123",
"Day_Of_Week": "Saturday",
}),
}
r = requests.post("https://api.graphjson.com/api/log", json=payload)
Bulk Logging
We also have a bulk logging API. It's very similar to the log API except instead of timestamp
and json
, you have timestamps
and jsons
. The endpoint is also /api/bulk-log
instead of /api/log
. 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",
"timestamps": [
int(time.time()),
int(time.time())
],
"jsons": [
json.dumps({
"Event": "Uber Ride",
"Price": 9.99,
"Driver_Rating": 5,
"Driver_ID": "123",
"Day_Of_Week": "Saturday",
}),
json.dumps({
"Event": "Uber Ride",
"Price": 9.99,
"Driver_Rating": 5,
"Driver_ID": "123",
"Day_Of_Week": "Saturday",
}),
],
}
r = requests.post("https://api.graphjson.com/api/bulk-log", json=payload)