# Search Everything — News API

> Search through millions of articles from over 150,000 large and small news sources and blogs. See the documentation

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

## Description

Search through millions of articles from over 150,000 large and small news sources and blogs. [See the documentation](https://newsapi.org/docs/endpoints/everything)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `q` | `string` | Yes | Keywords or phrases to search for |
| `searchin` | `string[]` | No | The fields to restrict your q search to. Default: all fields are searched |
| `sourceIds` | `string[]` | No | An array of source identifiers (maximum 20) for the news sources or blogs you want headlines from Options are loaded from the connected account. |
| `domains` | `string[]` | No | An array of domains to restrict the search to |
| `excludeDomains` | `string[]` | No | An array of domains to remove from the results |
| `from` | `string` | No | A date and optional time for the oldest article allowed. This should be in ISO 8601 format (e.g. 2024-11-01 or 2024-11-01T17:27:47) |
| `to` | `string` | No | A date and optional time for the newest article allowed. This should be in ISO 8601 format (e.g. 2024-11-01 or 2024-11-01T17:27:47) |
| `language` | `string` | No | The 2-letter ISO-639-1 code of the language you want to get headlines for |
| `sortBy` | `string` | No | The order to sort the articles in. Default: publishedAt |
| `maxResults` | `integer` | No | The maximum number of results to return. Must be between 1 and 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": "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: "news_api-search-everything",
  arguments: {
    q: "Query",
    searchin: ["Search In"],
  },
})
```

**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: "news_api-search-everything",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    news_api: { authProvisionId: "apn_xxxxxxx" },
    q: "Query",
    searchin: ["Search In"],
  },
})

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": "news_api-search-everything",
    "configured_props": {
      "news_api": { "authProvisionId": "apn_xxxxxxx" },
      "q": "Query",
      "searchin": ["Search In"]
    }
  }'
```

---

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