# Add Tasks

Add Yelp search tasks to scrape business listings

Add Yelp search tasks to scrape business listings. You can provide either a Yelp search URL or use `keyword` + `location` to build the search programmatically.

<Note>Crawler ID: `ac92974d3c1c9f8d3997767f090fa0b8`</Note>

## Headers

<ParamField header="Authorization" type="string" required>
  Your API authentication token. Value: `Token YOUR_API_KEY`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Request body format. Value: `application/json`
</ParamField>

## Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| **squid** | string | Yes | Hash of your squid configured with the Yelp Search Export crawler |
| **tasks** | array | Yes | Array of task objects |

## Task Object

You can either pass a `url` or use `keyword` + `location` (with optional `country`):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| **url** | string | No | Full Yelp search URL (e.g., `https://www.yelp.com/search?find_desc=Restaurants&find_loc=New+York`) |
| **keyword** | string | No | What you're looking for (business category or search term). Example: `Italian restaurant` |
| **location** | string | No | City or area to search in. Example: `New York, NY` |
| **country** | string | No | Country to scope the location list. Leave empty to use top worldwide cities |

<Note>
  Either `url` or `keyword` + `location` is required. When using `keyword` and `location`, filters set in the squid settings (price, sort, distance, etc.) are applied automatically.
</Note>

<Tip>
  To use advanced Yelp filters (cuisine type, outdoor seating, etc.), apply them on Yelp's website first and then copy the resulting URL.
</Tip>

## Code Examples

<CodeGroup>
```bash cURL (URL)
curl -X POST "https://api.lobstr.io/v1/tasks" \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "squid": "YOUR_SQUID_HASH",
    "tasks": [
      {
        "url": "https://www.yelp.com/search?find_desc=Restaurants&find_loc=New+York%2C+NY"
      }
    ]
  }'
```

```bash cURL (keyword + location)
curl -X POST "https://api.lobstr.io/v1/tasks" \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "squid": "YOUR_SQUID_HASH",
    "tasks": [
      {
        "keyword": "Italian restaurant",
        "location": "New York, NY",
        "country": "US"
      }
    ]
  }'
```

```python Python
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.lobstr.io/v1"
headers = {"Authorization": f"Token {API_KEY}"}

squid_id = "YOUR_SQUID_HASH"

# Option 1: use a full Yelp URL
payload = {
    "squid": squid_id,
    "tasks": [
        {"url": "https://www.yelp.com/search?find_desc=Restaurants&find_loc=New+York%2C+NY"}
    ]
}

# Option 2: use keyword + location (filters from squid settings apply)
payload = {
    "squid": squid_id,
    "tasks": [
        {"keyword": "Italian restaurant", "location": "New York, NY", "country": "US"}
    ]
}

response = requests.post(f"{BASE_URL}/tasks", headers=headers, json=payload)

data = response.json()
print(f"Added {len(data['tasks'])} tasks")
print(f"Duplicates skipped: {data['duplicated_count']}")
```
</CodeGroup>

## Response

```json 200
{
  "duplicated_count": 0,
  "tasks": [
    {
      "id": "82367f24d9450b2222080eed91662968",
      "created_at": "2025-07-17T09:06:47.287893",
      "is_active": true,
      "params": {
        "keyword": "Italian restaurant",
        "location": "New York, NY",
        "country": "US"
      },
      "module": 115,
      "object": "task"
    }
  ]
}
```
