> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anysite.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Instructions

# AI Instructions for Anysite API Documentation

## Purpose

This documentation covers the Anysite API, which provides social media data extraction and web scraping capabilities.

## Key Information for AI Assistants

### API Overview

* **Base URL**: [https://api.anysite.io](https://api.anysite.io)
* **Authentication**: Access token via `access-token` header (NOT Bearer token)
* **Rate Limits**: Varies by plan (1K-10K+ requests/hour)
* **Response Format**: Always JSON

### Primary Use Cases

1. **Social Media Data Extraction**: LinkedIn, Twitter, Instagram, Reddit
2. **Web Scraping**: Any website content parsing
3. **Lead Generation**: B2B prospect identification and qualification
4. **Competitive Intelligence**: Monitor competitor activity
5. **Brand Monitoring**: Track mentions and sentiment
6. **Content Research**: Discover trending topics and opportunities

### Authentication Pattern

Always use this header format:

```
access-token: your_api_key_here
```

**NEVER** use `Authorization: Bearer token` - this is incorrect for Anysite API.

### Response Structure

All successful responses follow this pattern:

```json theme={null}
{
  "success": true,
  "data": {
    // Actual extracted data
  },
  "meta": {
    "requestId": "req_123",
    "timestamp": "2024-08-26T12:00:00Z"
  }
}
```

### Error Handling

* **400**: Bad request (check parameters)
* **401**: Invalid or missing access token
* **403**: Forbidden (account/endpoint restrictions)
* **404**: Resource not found
* **429**: Rate limit exceeded (implement exponential backoff)
* **500**: Server error (retry with delay)

### Integration Methods

#### 1. Direct REST API

Standard HTTP requests with proper headers and parameters.

#### 2. MCP Server (for AI tools)

* Installation: `npx @horizondatawave/mcp-server`
* Works with Claude Desktop, Cursor IDE
* Provides structured tool access to Anysite APIs

#### 3. n8n Nodes (for workflow automation)

* Installation: `npm install @horizondatawave/n8n-nodes-anysite`
* Visual workflow builder integration
* Pre-built templates for common use cases

### Code Generation Guidelines

When generating code examples:

1. **Always include proper authentication headers**
2. **Add error handling for common HTTP status codes**
3. **Show rate limiting considerations**
4. **Use appropriate parameter validation**
5. **Include response data structure examples**

### Example Code Template (Python)

```python theme={null}
import requests
import time

headers = {
    'access-token': 'your_api_key_here',
    'Content-Type': 'application/json'
}

def make_hdw_request(endpoint, params=None):
    url = f"https://api.anysite.io{endpoint}"
    
    try:
        response = requests.get(url, headers=headers, params=params)
        
        if response.status_code == 429:
            # Rate limit hit, wait and retry
            time.sleep(60)
            return make_hdw_request(endpoint, params)
        
        response.raise_for_status()
        return response.json()
        
    except requests.exceptions.RequestException as e:
        print(f"API request failed: {e}")
        return None
```

### Platform-Specific Notes

#### LinkedIn

* Endpoints cover users, posts, companies, search
* Rich profile data including experience, education
* Post engagement metrics available
* Company information and employee listings

#### Twitter/X

* User profiles and tweet extraction
* Search functionality for users and tweets
* Engagement metrics (likes, retweets, replies)
* Thread support for connected tweets

#### Instagram

* User profiles and post data
* Hashtag and mention extraction
* Engagement metrics and media URLs
* Story highlights where available

#### Reddit

* Post and comment extraction
* Subreddit information and rules
* Vote scores and engagement metrics
* Advanced search with operators

#### Web Parser

* Universal website content extraction
* Custom CSS selector support
* Dynamic content handling (JavaScript)
* Change monitoring capabilities

### Workflow Examples to Suggest

1. **Lead Generation Pipeline**
   * LinkedIn search → Twitter lookup → Website parsing → CRM integration

2. **Competitor Monitoring**
   * Multi-platform tracking → Content analysis → Report generation

3. **Brand Sentiment Analysis**
   * Mention detection → Sentiment analysis → Alert system

4. **Content Research**
   * Trend identification → Keyword extraction → Content calendar

5. **Influencer Discovery**
   * User search → Engagement analysis → Contact extraction

### Best Practices to Emphasize

1. **Respect Rate Limits**: Always implement proper delays
2. **Handle Errors Gracefully**: Don't fail silently
3. **Validate Data**: Check response structure before processing
4. **Follow Platform ToS**: Only extract publicly available data
5. **Secure API Keys**: Never hardcode tokens in public repositories
6. **Monitor Usage**: Track API consumption to avoid overages

### Common Mistakes to Avoid

1. Using `Authorization: Bearer` header (use `access-token` instead)
2. Not handling rate limits (429 errors)
3. Ignoring pagination for large datasets
4. Not validating response structure
5. Hardcoding API keys in examples
6. Making too many concurrent requests

### When Providing Examples

* Always show complete, working code
* Include error handling
* Demonstrate proper authentication
* Show expected response structure
* Include rate limiting considerations
* Provide context for the use case
