An API for searching the youtube data api
- Make sure go is installed
- Define a
.env
file accordin to the.example-env
in the format:
DB_URI=your-postgres-link
GCP_APIKEY="your-gcp-api-key-1 your-gcp-api-key-2 your-gcp-api-key-3"
- Note: If you want to use multiple API Keys, they must be seperated by spaces and the entire string must be surrounded by quotes(")
- The Database used is cockroachDB but Postgres should also be compatible
- Run the project with
go run main.go
- Paginated Video Data fetched from Youtube API every 1 min
- Data fetched can be sorted based on preference
- Multiple GCP API Keys can be passed which automatically get switched based on quotas
-
Get All Videos:
GEThttp://localhost:8080/api/video/?size=4&page=0&sort=-pub_date
where,size
denotes the number of data per page,page
to define the current page andsort
to define the sorting order
Possible sorting orders:
title
,desc
,pub_date
,thumb_url
,url
andvideo_id
to sort based on descending order, add a-
infront like-pub_date
-
Get Video by VideoID:
GET http://localhost:8080/api/video/:videoId
where videoId
is the youtube video id fetched from the youtube data api
- Create Multiple Videos:
POSThttp://localhost:8080/api/video/
Accepts an array of video data in the following format
{
"title": "Video Title",
"desc": "Video Description",
"pub_date": "Video Publish Date in DateTime Format",
"thumb_url": "Video thumbnail url",
"video_id": "Youtube video id",
}
The video url is auto generated by it before the insertion