# VSCode Setup

Learn how to setup Visual Studio Code and GitHub Copilot to generate accurate Tomba API code using our `llms.txt` documentation file.

## Quick Use

For immediate access to Tomba API documentation in any chat window:

### GitHub Copilot Chat

In the GitHub Copilot chat window, type this command and VSCode will use Tomba API's `llms.txt` file to generate code:

```
#web https://docs.tomba.io/llms.txt
```

### Example Prompt

```
#web https://docs.tomba.io/llms.txt

Generate a Node.js function to find email addresses for employees at a company domain using the Tomba API. Include error handling and authentication.
```

This will fetch our complete API documentation and generate accurate code based on the latest information.

## Project-level Permanent Setup

For a more permanent solution, you can setup Tomba API's `llms.txt` file in your workspace so GitHub Copilot can use it by default.

### Method 1: Using .github/instructions (Recommended)

GitHub Copilot automatically reads instruction files from the `.github/instructions/` directory. Run this command in your project root:

```bash
curl -L https://docs.tomba.io/llms.txt --create-dirs -o .github/instructions/tomba.instructions.md
```

This creates a permanent reference that GitHub Copilot will automatically use when generating Tomba API code.

### Method 2: Workspace Instructions

You can also create a workspace-specific instructions file:

```bash
# Create docs directory if it doesn't exist
mkdir -p docs

# Download the Tomba API documentation
curl -L https://docs.tomba.io/llms.txt -o docs/tomba-api.md
```

Then reference it in your prompts:

```
@workspace /docs/tomba-api.md

Create a Python script to verify email addresses using Tomba API
```

## Configuration Tips

### 1. Enable GitHub Copilot Chat

Make sure you have the GitHub Copilot Chat extension installed:

- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "GitHub Copilot Chat"
- Install the extension

### 2. Authentication

Ensure you're signed in to GitHub Copilot:

- Open Command Palette (Ctrl+Shift+P)
- Type "GitHub Copilot: Sign In"
- Follow the authentication process

### 3. Workspace Settings

Add these settings to your workspace `settings.json` for better AI assistance:

```json
{
    "github.copilot.enable": {
        "*": true,
        "yaml": true,
        "plaintext": true,
        "markdown": true
    },
    "github.copilot.chat.welcomeMessage": "always"
}
```

## Example Usage

### Finding Email Addresses

**Prompt:**

```
Using the Tomba API, create a JavaScript function that finds all email addresses for a given domain. Use the domain search endpoint and include proper error handling.
```

**Generated Code:**

```javascript
const axios = require("axios");

async function findEmailsByDomain(domain) {
    try {
        const response = await axios.get(
            `https://api.tomba.io/v1/domain-search`,
            {
                params: {
                    domain: domain,
                },
                headers: {
                    "X-Tomba-Key": process.env.TOMBA_API_KEY,
                    "X-Tomba-Secret": process.env.TOMBA_SECRET_KEY,
                },
            },
        );

        return response.data;
    } catch (error) {
        if (error.response) {
            console.error("API Error:", error.response.data);
        } else {
            console.error("Network Error:", error.message);
        }
        throw error;
    }
}
```

### Email Verification

**Prompt:**

```
Create a Python function to verify if an email address is valid using Tomba's email verifier API.
```

**Generated Code:**

```python
import requests
import os

def verify_email(email):
    """
    Verify an email address using Tomba API

    Args:
        email (str): Email address to verify

    Returns:
        dict: Verification result
    """
    url = "https://api.tomba.io/v1/email-verifier"

    headers = {
        "X-Tomba-Key": os.getenv("TOMBA_API_KEY"),
        "X-Tomba-Secret": os.getenv("TOMBA_SECRET_KEY")
    }

    params = {"email": email}

    try:
        response = requests.get(url, headers=headers, params=params)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"Error verifying email: {e}")
        return None
```

## Best Practices

### 1. Be Specific in Prompts

Instead of:

```
Generate Tomba API code
```

Use:

```
Create a Node.js function using Tomba API to find the CEO's email address for a company domain, with rate limiting and error handling
```

### 2. Include Context

Reference specific endpoints or features:

```
Using Tomba's LinkedIn finder endpoint, create a function that finds email addresses from LinkedIn profiles
```

### 3. Specify Programming Language

Always specify your preferred language:

```
Generate a PHP class for Tomba email verification with proper exception handling
```

## Troubleshooting

### GitHub Copilot Not Using Instructions

1. Ensure the `.github/instructions/` directory is in your project root
2. Restart VS Code after adding instruction files
3. Try referencing the file explicitly: `@workspace #file:tomba.instructions.md`

### API Key Issues

Make sure your prompts include environment variable usage:

```
Generate code that uses TOMBA_API_KEY and TOMBA_SECRET_KEY environment variables for authentication
```

### Rate Limiting

Include rate limiting in your prompts:

```
Create a Tomba API client that respects rate limits and includes retry logic
```

## Additional Resources

- [GitHub Copilot Documentation](https://docs.github.com/en/copilot)
- [VS Code GitHub Copilot Extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot)
- [Tomba API Documentation](/api)
- [Authentication Guide](/authentication)
