# Add Tasks

Add keyword or topic tasks to scrape Google News articles

Add keyword or topic tasks to scrape Google News articles. Each task represents a search query or topic that will fetch matching articles from Google News.

<Note>Crawler ID: `06faf01896336c01ffb5e96d13dd406c`</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 google-news-search-export crawler |
| **tasks** | array | Yes | Array of task objects, each containing a `keyword` field |

## Task Object

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| **keyword** | string | Yes | A search query (e.g., `climate change`) **or** a predefined Google News topic in CAPS: `WORLD`, `NATION`, `BUSINESS`, `TECHNOLOGY`, `ENTERTAINMENT`, `SPORTS`, `SCIENCE`, `HEALTH` |

<Tip>
  To scrape a specific topic page or section URL from news.google.com, set `topic_url` in the squid settings instead — task keywords are ignored when `topic_url` is set.
</Tip>

<Note>
  Configure time range, language, and date filters in the squid settings.
</Note>

## Code Examples

<CodeGroup>
```bash cURL
curl -X POST "https://api.lobstr.io/v1/tasks" \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tasks": [
      {"keyword": "crab"},
      {"keyword": "climate change"}
    ],
    "squid": "YOUR_SQUID_HASH"
  }'
```

```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"

# Add keyword-based news search tasks
response = requests.post(f"{BASE_URL}/tasks",
    headers=headers,
    json={
        "squid": squid_id,
        "tasks": [
            {"keyword": "crab"},
            {"keyword": "climate change"}
        ]
    }
)

data = response.json()
print(f"Added {len(data['tasks'])} tasks")
for task in data["tasks"]:
    print(f"  {task['id']}: {task['params']['keyword']}")
```
</CodeGroup>

## Response

```json 200
{
  "duplicated_count": 0,
  "tasks": [
    {
      "id": "5f5ccd42b74cf18196dcb7fe14fb8030",
      "created_at": "2025-07-04T04:51:12.532884",
      "is_active": true,
      "params": {
        "keyword": "crab"
      },
      "module": 131,
      "object": "task"
    }
  ]
}
```
