Skip to content

Instantly share code, notes, and snippets.

@TheBeege
Created March 17, 2020 06:48
Show Gist options
  • Save TheBeege/511fae839bc216a6742188ee45908e74 to your computer and use it in GitHub Desktop.
Save TheBeege/511fae839bc216a6742188ee45908e74 to your computer and use it in GitHub Desktop.
API Examples for Jazzy
{
"example_api_path": "/v1/video/1/view/count?bucket=day&start_time=1583822151&end_time=1584426951",
"example_descrption": "The API path describes the kind of data we're asking for. We're asking for information about a video with an ID of 1. Specifically, we're asking for the view count. Everything up to the ? is telling the API what the thing is we're asking for. After the ? is telling API how we want the thing. These can be anything we want. In this example, I'm telling it i want data to be bucketed by day. I want the start time to be at some unix timestamp (I recommend googling and/or checking epochconverter.com) and the end time to be at some unix timestamp. I think an API like this would accomplish the example you described and shows kind of general design tools. Below, we'll cover example data output that the client would use.",
"total_views": 43,
"view_counts": [
{
"year": 2020,
"month": 03,
"day": 10,
"count": 10
},
{
"year": 2020,
"month": 03,
"day": 11,
"count": 13
},
{
"year": 2020,
"month": 03,
"day": 12,
"count": 20
}
]
}
{
"example_api_path": "/v1/video/1/view?start_time=1583822151&end_time=1584426951",
"example_descrption": "In this case, we ask for the individual views, and we make the client do the work of adding things together. This IS NOT recommended for large amounts of data. Video views is actually a terrible example for this, but I want to show the example structure. Bucketing doesn't make sense here because we're showing each individual event. Please note that based on the fields, there should be 20 view objects, but I didn't want to type all that.",
"total": 195,
"count_per_page": 20,
"current_page": 0,
"total_pages": 10,
"views": [
{
"timestamp": 1583822171,
"watch_duration_seconds": 100,
"account_id": 11111,
"liked": false,
"referrer": "email"
},
{
"timestamp": 1583822271,
"watch_duration_seconds": 10,
"account_id": 11121,
"liked": false,
"referrer": "feed"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment