pyytdata
pyytdata copied to clipboard
Implement an API cache for development.
Implementation of local API cache will help in avoiding rate limits of youtube data v3 API.
I would like to work on this. this is a great opportunity for me to study APIs
Sure
what route do you suggest
I am a beginner to this field
Can we use the cache argument from build function??
Can we use the cache argument from the build function??
didn't understand, which build function.
when I created this ticket I had an approach in mind i.e to save the JSON response returned by YouTube Data V3 API in a JSON file, we can track the input(input of public APIs like PyYtData class or vid_info function ) in the JSON file itself and if the input is present in JSON we simply return the response from JSON file instead of querying to YouTube API.
This will be useful in local testing only, you need to make changes in VideoInfo and ChannelInfo classes to avoid querying to Youtube API if the result is there for the particular request in the JSON file.
I hope you got my point
Yes I got your point. I will commit the code in couple of days
Shall we use redis for this ???
No, we should stick with the json file. We are using this to avoid API rate limit while doing development locally.
No, we should stick with the json file. We are using this to avoid API rate limits while doing development locally.
Ok
I am working on it . Just need to study it a bit more since I have not done before
No probs, take your time
I am not able to get the data from previous query into a JSON how should I do it
Save the json response returned by YouTube Data API V3 into a json file and next time if you are querying the same thing query to json file instead of YouTube Data API V3
for i in range(self.maxlen): vid = VidInfo(self.type, self.keyword, self.maxlen, i) rslt.append(vid) return rslt
do you mean this
No, I am talking about this point, https://github.com/Agent-Hellboy/pyytdata/blob/master/pyytdata/util/querier.py#L35
here you should do all the operations of saving the whole response https://github.com/Agent-Hellboy/pyytdata/blob/master/pyytdata/util/querier.py#L46 in a JSON file if the result is not present else return the result from JSON file instead of querying to the YouTube API
we will get a response after req.execute() in fetch method runs right??. if I store req in JSON then it will be just that request not the response??
if I store req in JSON then it will be just that request not the response??
No, you will store both request and response, request as a key in JSON object and response and a value.
we will get a response after req.execute() in fetch method runs right
Yes, inside this you should check if the keyboard is inside your cache if yes you should return it as it is without querying to youtube API. https://github.com/Agent-Hellboy/pyytdata/blob/3ce31fc200ddec2b42c88b9edca038240e96b3f9/pyytdata/util/querier.py#L28