# Search News — World News API

> Search and filter news. See the docs here. Calling this endpoint requires 1 point

- Key: `world_news_api-search-news`
- Type: Action (Read-only)
- Version: 0.0.2
- App: World News API (`world_news_api`) — https://pipedream.com/apps/world-news-api.md
- This page (HTML): https://pipedream.com/apps/world-news-api/actions/search-news
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/world_news_api/actions/search-news/search-news.mjs

## Description

Search and filter news. [See the docs here](https://worldnewsapi.com/docs/#Search-News). **Calling this endpoint requires 1 point**

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `text` | `string` | No | The text to match in the news content. |
| `sourceCountries` | `string[]` | No | List of ISO 3166 country codes from which the news should originate. |
| `language` | `string` | No | The ISO 6391 language code of the news. |
| `minSentiment` | `string` | No | The minimum sentiment of the news. |
| `maxSentiment` | `string` | No | The maximum sentiment of the news. |
| `earliestPublishedDate` | `string` | No | The news must have been published after this date. YYYY-MM-DD HH:MM:SS format |
| `latestPublishedDate` | `string` | No | The news must have been published before this date. YYYY-MM-DD HH:MM:SS format |
| `newsSources` | `string[]` | No | A list of news sources from which the news should originate. |
| `authors` | `string[]` | No | A list of authors of the news. |
| `entities` | `string[]` | No | Filter news by entities (see semantic types). |
| `locationFilter` | `string` | No | Filter news by radius around a certain location. Format is latitude,longitude,radius in kilometers |
| `sort` | `string` | No | Sort the news by a certain field. |
| `sortDirection` | `string` | No | Sort the news in ascending or descending order. |
| `offset` | `integer` | No | The number of news to skip in range. (0-1000) |
| `number` | `integer` | No | The number of news to return in range. (0-100) |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "world_news_api",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "world_news_api-search-news",
  arguments: {
    text: "Text",
    sourceCountries: ["Source Countries"],
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "world_news_api-search-news",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    world_news_api: { authProvisionId: "apn_xxxxxxx" },
    text: "Text",
    sourceCountries: ["Source Countries"],
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "world_news_api-search-news",
    "configured_props": {
      "world_news_api": { "authProvisionId": "apn_xxxxxxx" },
      "text": "Text",
      "sourceCountries": ["Source Countries"]
    }
  }'
```

---

- App: https://pipedream.com/apps/world-news-api.md · All apps: https://pipedream.com/apps
