# n8n-nodes-google-search-console

![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-logo.png)

An n8n community node for integrating with the Google Search Console API. This node provides comprehensive access to GSC data and operations for SEO workflow automation.

## Features

### Supported Operations

- **List Sites**: Get all verified sites in your Search Console account
- **List Sitemaps**: Retrieve all sitemaps for a specific site  
- **URL Inspection**: Check indexing status and details for specific URLs
- **Get Sitemap Details**: Get detailed information about a specific sitemap
- **Submit Sitemap**: Add new sitemaps to Google Search Console
- **Delete Sitemap**: Remove sitemaps from Google Search Console

### Key Benefits

- ✅ **Comprehensive API Coverage**: Access all major GSC operations
- ✅ **Service Account Authentication**: Secure, server-to-server authentication
- ✅ **Error Handling**: Robust error handling with detailed messages
- ✅ **TypeScript Support**: Full TypeScript implementation for reliability
- ✅ **Production Ready**: Built following N8N best practices

## Installation

### Method 1: Install from NPM (Recommended)

1. Navigate to your N8N installation
2. Open **Settings** → **Community Nodes**
3. Click **Install**
4. Enter: `n8n-nodes-google-search-console`
5. Click **Install** and restart N8N

### Method 2: Manual Installation

1. Download the latest release from GitHub
2. Extract to your N8N custom nodes directory
3. Run `npm install` in the extracted folder
4. Restart N8N

## Setup

### 1. Google Cloud Console Setup

1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing one
3. Enable the **Google Search Console API**
4. Create a **Service Account**
5. Download the JSON key file

### 2. Google Search Console Setup

1. Go to [Google Search Console](https://search.google.com/search-console)
2. Add the service account email as a user to your property
3. Grant at least **Restricted** access

### 3. N8N Credentials Setup

1. In N8N, create new **Google Search Console API** credentials
2. Copy the service account email from your JSON key
3. Copy the private key (including BEGIN/END lines)
4. Save the credentials

## Usage Examples

### Basic Site Listing

```json
{
  "operation": "listSites"
}
```

### URL Inspection

```json
{
  "operation": "urlInspection",
  "siteUrl": "https://example.com/",
  "inspectionUrl": "https://example.com/important-page"
}
```

### Sitemap Management

```json
{
  "operation": "submitSitemap",
  "siteUrl": "https://example.com/",
  "sitemapUrl": "https://example.com/sitemap.xml"
}
```

## API Reference

### Operations

| Operation | Description | Required Parameters |
|-----------|-------------|-------------------|
| `listSites` | List all verified sites | None |
| `listSitemaps` | List sitemaps for a site | `siteUrl` |
| `urlInspection` | Inspect URL indexing status | `siteUrl`, `inspectionUrl` |
| `getSitemap` | Get sitemap details | `siteUrl`, `sitemapUrl` |
| `submitSitemap` | Submit new sitemap | `siteUrl`, `sitemapUrl` |
| `deleteSitemap` | Remove sitemap | `siteUrl`, `sitemapUrl` |

### Response Format

All operations return structured JSON data from the Google Search Console API. Successful operations include the raw API response, while errors are handled gracefully with descriptive messages.

## Error Handling

The node includes comprehensive error handling:

- **Authentication errors**: Clear messages for credential issues
- **Permission errors**: Helpful guidance for access problems  
- **API errors**: Detailed error information from Google
- **Validation errors**: Parameter validation with helpful hints

## Development

### Local Setup

```bash
# Clone the repository
git clone https://github.com/your-username/n8n-nodes-google-search-console
cd n8n-nodes-google-search-console

# Install dependencies
npm install

# Build the project
npm run build

# Run linting
npm run lint
```

### Testing

```bash
# Run tests
npm test

# Run linting
npm run lint

# Format code
npm run format
```

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Changelog

### v1.0.0
- Initial release
- Support for 6 core GSC operations
- Service Account authentication
- Comprehensive error handling
- Full TypeScript implementation

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- 📖 [N8N Documentation](https://docs.n8n.io/)
- 📧 [Google Search Console API Docs](https://developers.google.com/webmaster-tools/)
- 🐛 [Report Issues](https://github.com/your-username/n8n-nodes-google-search-console/issues)

---

Made with ❤️ for the N8N community