title: How to avoid rebuilding Google api client each time you make an api request python
body: <p>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 form
  Here is the code:</p>
  <pre><code>import googleapiclient.discovery
  
  def myFunc():
        youtube = googleapiclient.discovery.build(
          api_service_name, api_version, developerKey=api_key)
  
      request = youtube.search().list(
          part=&quot;id&quot;,
          maxResults=25,
          q=&quot;surfing&quot;,
      )
      youtube_api_response = request.execute()
  
      for object in youtube_api_response[&quot;items&quot;]:
        # my logic here
  
  </code></pre>
  <p>Now building the api client using</p>
  <pre><code>googleapiclient.discovery.build(api_service_name, api_version, developerKey=api_key)
  </code></pre>
  <p>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.</p>