How to load data from Google Search Console to MongoDB
Learn how to use Airbyte to synchronize your Google Search Console data into MongoDB within minutes.


Building your pipeline or Using Airbyte
Airbyte is the only open source solution empowering data teams to meet all their growing custom business demands in the new AI era.
- Inconsistent and inaccurate data
- Laborious and expensive
- Brittle and inflexible
- Reliable and accurate
- Extensible and scalable for all your needs
- Deployed and governed your way
Start syncing with Airbyte in 3 easy steps within 10 minutes



Take a virtual tour
Demo video of Airbyte Cloud
Demo video of AI Connector Builder
Setup Complexities simplified!
Simple & Easy to use Interface
Airbyte is built to get out of your way. Our clean, modern interface walks you through setup, so you can go from zero to sync in minutes—without deep technical expertise.
Guided Tour: Assisting you in building connections
Whether you’re setting up your first connection or managing complex syncs, Airbyte’s UI and documentation help you move with confidence. No guesswork. Just clarity.
Airbyte AI Assistant that will act as your sidekick in building your data pipelines in Minutes
Airbyte’s built-in assistant helps you choose sources, set destinations, and configure syncs quickly. It’s like having a data engineer on call—without the overhead.
What sets Airbyte Apart
Modern GenAI Workflows
Move Large Volumes, Fast
An Extensible Open-Source Standard
Full Control & Security
Fully Featured & Integrated
Enterprise Support with SLAs
What our users say

Raman Singh
Predictable, straightforward pricing model that simplified budgeting and significantly reduced overall spend

Chase Zieman

“Airbyte helped us accelerate our progress by years, compared to our competitors. We don’t need to worry about connectors and focus on creating value for our users instead of building infrastructure. That’s priceless. The time and energy saved allows us to disrupt and grow faster.”

Rupak Patel
"With Airbyte, we could just push a few buttons, allow API access, and bring all the data into Google BigQuery. By blending all the different marketing data sources, we can gain valuable insights."
How to Sync to Manually
First, you'll need access to the Google Search Console API. Go to the Google Cloud Console and create a new project. Enable the Search Console API for your project. Then, set up OAuth 2.0 credentials by creating a new set of credentials and downloading the JSON file. This file will allow your script to authenticate and access data from the Google Search Console.
Ensure you have Python installed on your machine, as it will be used to interact with the API. You will also need to install necessary Python libraries, such as `google-auth`, `google-auth-oauthlib`, `google-auth-httplib2`, and `google-api-python-client`, using pip. Additionally, install the `pymongo` library to interact with MongoDB. Run the following command in your terminal:
```bash
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client pymongo
```
Write a Python script to authenticate using the credentials JSON file. Use the OAuth2 flow to obtain access tokens. Here's a basic code snippet to get you started:
```python
from google.oauth2 import service_account
from googleapiclient.discovery import build
# Load credentials from JSON file
credentials = service_account.Credentials.from_service_account_file(
'path/to/your/credentials.json',
scopes=['https://www.googleapis.com/auth/webmasters.readonly']
)
# Build the service
service = build('webmasters', 'v3', credentials=credentials)
```
Use the authenticated service object to query data from Google Search Console. Define the site URL, date range, and dimensions you wish to retrieve. Here's an example of how to query the API:
```python
site_url = 'https://www.example.com' # Replace with your site URL
request = {
'startDate': '2023-01-01',
'endDate': '2023-01-31',
'dimensions': ['query']
}
response = service.searchanalytics().query(siteUrl=site_url, body=request).execute()
data = response.get('rows', [])
```
Once you have the data, transform it into a format suitable for MongoDB. Typically, this involves converting the response data into a list of dictionaries, where each dictionary represents a document to be inserted into MongoDB:
```python
documents = []
for row in data:
document = {
'query': row['keys'][0],
'clicks': row['clicks'],
'impressions': row['impressions'],
'ctr': row['ctr'],
'position': row['position']
}
documents.append(document)
```
Establish a connection to your MongoDB instance. You can use the `pymongo` library to connect to a local or remote MongoDB database. Here’s an example of how to connect and select a database and collection:
```python
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
db = client['your_database_name']
collection = db['your_collection_name']
```
Finally, insert the transformed data into MongoDB. Use the `insert_many()` method to add the list of documents to your collection:
```python
if documents:
collection.insert_many(documents)
print(f"Inserted {len(documents)} documents into MongoDB.")
else:
print("No data to insert.")
```
---
By following these steps, you can programmatically retrieve data from Google Search Console and store it in a MongoDB database without relying on third-party connectors. Adjust the scripts as necessary to fit your specific use case and data requirements.