Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3755

How to avoid rebuilding Google api client each time you make an api request python

$
0
0

In my Django web application i have this function that makes a request to google's youtube api, this function gets excuted each time a user submits a formHere is the code:

import googleapiclient.discoverydef myFunc():      youtube = googleapiclient.discovery.build(        api_service_name, api_version, developerKey=api_key)    request = youtube.search().list(        part="id",        maxResults=25,        q="surfing",    )    youtube_api_response = request.execute()    for object in youtube_api_response["items"]:      # my logic here

Now building the api client using

googleapiclient.discovery.build(api_service_name, api_version, developerKey=api_key)

So building this way each time a user submits a form will require a lot of time and slow down the website.Is there a way to store this build somehow or reuse the same one each time without the need of building again and again to improve the performance.


Viewing all articles
Browse latest Browse all 3755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>