> For the complete documentation index, see [llms.txt](https://docs.yetanotherapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yetanotherapi.com/llm-web-scraper/best-practices.md).

# Best Practices

### Best Practices

#### 1. Prompt Engineering

**Clear and Specific Instructions**

```json
// ❌ Bad
{
    "prompt": "Get product information"
}

// ✅ Good
{
    "prompt": "Extract the product's name, current price, original price (if on sale), available sizes, and color options. For prices, include the currency symbol."
}
```

**Define Expected Format**

```json
// ❌ Bad
{
    "prompt": "What are the key features of this product?"
}

// ✅ Good
{
    "prompt": "List the product's key features as an array of strings, with each feature being a concise single sentence."
}
```

**Include Validation Rules**

```json
// ❌ Bad
{
    "prompt": "Get the product price and rating"
}

// ✅ Good
{
    "prompt": "Extract the product price (as a number without currency symbol) and rating (must be between 0 and 5, with one decimal place)"
}
```

#### 2. Data Structuring

**Clear Hierarchy**

```json
// ❌ Bad
{
    "prompt": "Get all prices from the page"
}

// ✅ Good
{
    "prompt": "Extract pricing information in this structure: base_price (number), additional_options (array of objects with name and price), discounts (array of objects with description and amount)"
}
```

**Handle Missing Data**

```json
// ❌ Bad
{
    "prompt": "Get the author's name and bio"
}

// ✅ Good
{
    "prompt": "Extract the author's details with these rules: name (string, use 'Anonymous' if not found), bio (string, use null if not present), role (string, use 'Contributor' if not specified)"
}
```

#### 3. Performance Optimization

**Focused Extraction**

```json
// ❌ Bad
{
    "prompt": "Get everything from the page"
}

// ✅ Good
{
    "prompt": "Extract only the technical specifications table, converting it to a JSON object with spec_name as keys and spec_value as values"
}
```

**Batch Processing**

```json
// ❌ Bad: Multiple separate requests
{
    "prompt": "Get product prices"
}
{
    "prompt": "Get product features"
}

// ✅ Good: Single comprehensive request
{
    "prompt": "Extract all product information in a single structured response: prices (object), features (array), specifications (object)"
}
```
