> ## Content Index
> Fetch the complete content index at: https://serpapi.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Using SerpApi in Google Colab
- URL: https://serpapi.com/blog/using-serpapi-in-google-colab/
- Published: 2024-08-08T05:42:22.000Z
- Updated: 2024-08-08T05:42:22.000Z
- Description: Create an easily shareable SerpApi demo project using Google Colab. Run your Python code on the internet for free!
- Author: Hilman Ramadhan
- Tags: Python

One way to try out SerpApi or to create an easily shareable demo project is to use Google Colab.

Google Colab is a free cloud service that provides a Python development environment. It enables us to write and execute Python code through our browsers without any setup.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2024/08/using-Google-Colab-in-SerpApi-1.png)

Using Google Colab in SerpApi

**Step By Step**

1. Setup account  
Login to your Google account and open the [Google Colab website](https://colab.research.google.com/).
2. Setup a new notebook  
Create a new notebook

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2024/08/CleanShot-2024-08-08-at-13.23.59.png)

how to create a new notebook at Google Colab

1. Setup SerpApi account  
Register at serpapi.com and grab your API Key from the dashboard.
2. Setup API Key  
Paste your SerpAPI API Key on the "secrets tab" to ensure your API Key stays safe.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2024/08/CleanShot-2024-08-08-at-13.26.34.png)

Save secret env file on Google Colab

You can name it whatever you want, for example `SERPAPI_API_KEY` and paste your real API key into the value section. Don't forget to toggle the button to allow the notebook to access this key.  
  
5\. Access the API Key  
To access the API Key programmatically, use the `userdata` method from Google Colab.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2024/08/CleanShot-2024-08-08-at-13.30.01.png)

Now we have the `SERPAPI_API_KEY` variable that we can use everywhere.

> Don't forget to click the "play" button on the left side of the code block, to run each code block.

1. Install SerpApi Python package  
Run `!pip install google-search-results` on the code section
2. Basic sample  
Now, let's try the basic Google Search API

```python
from serpapi import GoogleSearch

params = {
  "q": "Tea and Coffee",
  "location": "Austin, Texas, United States",
  "hl": "en",
  "gl": "us",
  "google_domain": "google.com",
  "api_key": SERPAPI_API_KEY
}

search = GoogleSearch(params)
results = search.get_dict()
print(results)
```

Try to run this code and see the result!

**Share your Google Colab project**

If you're creating a prototype or a demo project to share with your teammates, you can click the "share" button on the top right corner. You can choose either to allow specific users or make it public. Now anyone can check out your SerpApi project!