# Google Indexing API Bulk URL Submission (`mabdulmoghni/google-indexing-api-bulk-url-submission`) Actor

This Actor allows you to submit multiple URLs for indexing in bulk through Google's Indexing API. It avoids the need to manually request each URL to be indexed via the Google Search Console interface. With this tool, you can quickly submit up to 100 URLs at once.

- **URL**: https://apify.com/mabdulmoghni/google-indexing-api-bulk-url-submission.md
- **Developed by:** [Mohamed Moo](https://apify.com/mabdulmoghni) (community)
- **Categories:** SEO tools, E-commerce, Automation
- **Stats:** 103 total users, 1 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Google Indexing API Bulk URL Submission - Apify Actor

### Getting Started

This script allows you to submit multiple URLs for indexing in bulk through Google's Indexing API. It avoids the need to manually request each URL to be indexed via the Google Search Console interface. With this tool, you can quickly submit up to 100 URLs at once.

#### How to run the actor on Apify

1. Ensure you have access to Apify platform and an active Apify account.
2. Create a new Apify actor or use an existing one.
3. Upload the `service_account.json` file, which contains your Google service account credentials.
4. Provide a list of URLs either through a `urls.txt` file or by using a `sitemapUrl` input.
5. IF there's more than 100 URL. MAke sure you've increased your Gogole Web Search Indexing API quota limit 'Publish requests' and limit 'Publish requests per day'. the default is 200 by Google.
6. Ensure you have verified your website ownership in Google Search Console.
7. Run the actor. The actor will submit URLs in bulk to Google's Indexing API.

Once the actor completes execution, it will log the submission results and push them to the Apify dataset.

### What the actor does and why it is helpful

#### **What it does:**

This actor automates the process of submitting multiple URLs for indexing using Google's Indexing API. Normally, Google allows only one URL to be submitted at a time through its Search Console interface. This actor enables you to submit up to 100 URLs in a single batch request, thus saving you time and effort when you need to index large numbers of pages.

#### **Why it's helpful:**

Google's Indexing API is typically used to notify Google when new or updated content is available on your site. It is particularly useful for quick content updates, especially for pages like news articles, job listings, or product pages. This script is designed to streamline the process of submitting URLs, bypassing the manual submission process in Search Console.

#### **Who should use this actor:**

This tool is ideal for:

- Website owners or webmasters who need to quickly index large numbers of URLs (e.g., news websites, e-commerce sites, blogs).
- SEO professionals looking to improve search engine visibility by efficiently indexing new or updated content.
- Developers who need to automate the URL indexing process for sites with frequent content updates.

### Input required to run the actor

The actor requires the following inputs:

1. **service_account** (Required): Your Google service account JSON file that contains credentials for using the Indexing API.
   - Example: `"service_account": "YOUR_JSON_CREDENTIALS_HERE"`

2. **urlsTxt** (Required, one of `urlsTxt` or `sitemapUrl`): A plain text file containing the URLs that you want to be indexed. Each URL should be on a separate line.
   - Example: `"urlsTxt": "https://example.com/page1
     https://example.com/page2"`

3. **sitemapUrl** (Optional, one of `urlsTxt` or `sitemapUrl`): A URL pointing to a sitemap XML file that contains the URLs you want to index.
   - Example: `"sitemapUrl": "https://example.com/sitemap.xml"`

### How the Google Indexing API works

Google allows you to submit URLs for indexing individually via the Search Console interface. However, with the Google Indexing API, you can submit URLs in bulk by sending them to Google's servers in a single request. The API is subject to quotas:

- By default, Only 200 URLs can be submitted per request batch daily.
- You are allowed to submit a maximum of 200 URLs per day.
- For submitting more URLs, Submit a quota increase request from Google Web Search Indexing API 'Publish requests' and limit 'Publish requests per day'.

This script uses the Indexing API to send up to 2000 URLs at once, and it ensures that your URLs are submitted efficiently and within these limits.

### Setting up the Google Indexing API

#### First, set up access to the Indexing API in Google Cloud Platform

Follow these instructions to set up access to the Google Indexing API:

1. Go to the [Google Indexing API setup page](https://developers.google.com/search/apis/indexing-api/v3/prereqs).
2. Create a new project in Google Cloud Console.
3. Enable the Indexing API for your project.
4. Download the JSON credentials file containing your service account information.

Save the file as `service_account.json` and upload it to Apify.

#### Verify Site Ownership in Google Search Console

To submit URLs for indexing, you must verify ownership of the site in Google Search Console:

1. Go to Google Search Console.
2. Select your property and navigate to "Settings" -> "Users and Permissions."
3. Add the service account email address (from `service_account.json`) as an owner.

The service account email is found in the `client_email` field in your JSON key, and it should look something like:

```
"client_email": "my-service-account@test-project-xx.google.com.iam.gserviceaccount.com"
```

4. Add this email as an owner (delegated) to your Google Search Console property.

### Quotas

Google imposes limits on how many URLs you can submit for indexing:

- **100 URLs per request batch**: You can submit up to 100 URLs in a single request.
- **200 URLs per day**: You can submit up to 200 URLs in total per day.
- For submitting more URLs, Submit a quota increase request from Google Web Search Indexing API 'Publish requests' and limit 'Publish requests per day'.

Ensure you stay within these quotas when using the API.

### Sample INPUT for Running the Actor

#### Example of `service_account`:

```json
{
  "service_account": "{"type": "service_account", "project_id": "my-project-id", "private_key_id": "abc123", "private_key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----", "client_email": "my-service-account@my-project-id.iam.gserviceaccount.com", "client_id": "1234567890.apps.googleusercontent.com", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleap...
}
```

#### Example of `urlsTxt`:

```txt
https://example.com/page1
https://example.com/page2
https://example.com/page3
```

#### Example of `sitemapUrl`:

```json
{
  "sitemapUrl": "https://example.com/sitemap.xml"
}
```

### Example Output

#### Successful Response:

```json
{
  "url": "https://example.com/page1",
  "submitted": true,
  "success": true,
  "failureReason": "",
  "rawResponse": "HTTP/1.1 200 OK
Content-Type: application/json
..."
}
```

#### Failed Response:

```json
{
  "url": "https://example.com/page2",
  "submitted": true,
  "success": false,
  "failureReason": "429 Quota exceeded for quota metric 'Publish requests'",
  "rawResponse": "HTTP/1.1 429 Too Many Requests
Content-Type: application/json
..."
}
```

### Conclusion

This script makes it easy to submit multiple URLs for indexing using Google's Indexing API. Instead of submitting URLs one by one via the Search Console, you can automate the entire process and handle batches of up to 2000 URLs at once. This can save you valuable time and make it easier to keep your content indexed and updated in Google's search results.

Good luck and happy indexing!!

# Actor input Schema

## `urlsTxt` (type: `string`):

Paste one URL per line. Cannot be used with 'Sitemap URL'.

## `sitemapUrl` (type: `string`):

Provide a sitemap.xml URL (e.g. https://example.com/sitemap.xml). Cannot be used with 'URLs Text'.

## `serviceAccount` (type: `string`):

Paste the full contents of your service_account.json file here.

## Actor input object example

```json
{
  "urlsTxt": "https://example.com/\nhttps://example.com/products/",
  "sitemapUrl": "https://example.com/sitemap.xml",
  "serviceAccount": "{\n  \"type\": \"service_account\",\n  \"project_id\": \"your-project-id\",\n  \"private_key_id\": \"your-private-key-id\",\n  \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nYOUR_PRIVATE_KEY\\n-----END PRIVATE KEY-----\\n\",\n  \"client_email\": \"your-service-account@your-project.iam.gserviceaccount.com\",\n  \"client_id\": \"your-client-id\",\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n  \"token_uri\": \"https://oauth2.googleapis.com/token\",\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n  \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/your-service-account@your-project.iam.gserviceaccount.com\"\n}"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urlsTxt": `https://example.com/
https://example.com/products/`,
    "sitemapUrl": "https://example.com/sitemap.xml",
    "serviceAccount": `{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key_id": "your-private-key-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n",
  "client_email": "your-service-account@your-project.iam.gserviceaccount.com",
  "client_id": "your-client-id",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-service-account@your-project.iam.gserviceaccount.com"
}`
};

// Run the Actor and wait for it to finish
const run = await client.actor("mabdulmoghni/google-indexing-api-bulk-url-submission").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urlsTxt": """https://example.com/
https://example.com/products/""",
    "sitemapUrl": "https://example.com/sitemap.xml",
    "serviceAccount": """{
  \"type\": \"service_account\",
  \"project_id\": \"your-project-id\",
  \"private_key_id\": \"your-private-key-id\",
  \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nYOUR_PRIVATE_KEY\\n-----END PRIVATE KEY-----\\n\",
  \"client_email\": \"your-service-account@your-project.iam.gserviceaccount.com\",
  \"client_id\": \"your-client-id\",
  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",
  \"token_uri\": \"https://oauth2.googleapis.com/token\",
  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",
  \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/your-service-account@your-project.iam.gserviceaccount.com\"
}""",
}

# Run the Actor and wait for it to finish
run = client.actor("mabdulmoghni/google-indexing-api-bulk-url-submission").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urlsTxt": "https://example.com/\\nhttps://example.com/products/",
  "sitemapUrl": "https://example.com/sitemap.xml",
  "serviceAccount": "{\\n  \\"type\\": \\"service_account\\",\\n  \\"project_id\\": \\"your-project-id\\",\\n  \\"private_key_id\\": \\"your-private-key-id\\",\\n  \\"private_key\\": \\"-----BEGIN PRIVATE KEY-----\\\\nYOUR_PRIVATE_KEY\\\\n-----END PRIVATE KEY-----\\\\n\\",\\n  \\"client_email\\": \\"your-service-account@your-project.iam.gserviceaccount.com\\",\\n  \\"client_id\\": \\"your-client-id\\",\\n  \\"auth_uri\\": \\"https://accounts.google.com/o/oauth2/auth\\",\\n  \\"token_uri\\": \\"https://oauth2.googleapis.com/token\\",\\n  \\"auth_provider_x509_cert_url\\": \\"https://www.googleapis.com/oauth2/v1/certs\\",\\n  \\"client_x509_cert_url\\": \\"https://www.googleapis.com/robot/v1/metadata/x509/your-service-account@your-project.iam.gserviceaccount.com\\"\\n}"
}' |
apify call mabdulmoghni/google-indexing-api-bulk-url-submission --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mabdulmoghni/google-indexing-api-bulk-url-submission"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/N479ocosLg3wHVPan/builds/jJenG8snpjkM8Nm8O/openapi.json
