# Google data in LangChain. Pay per record.

> Get Google search, news, images and shopping into LangChain: one HTTPS call per operation, a free quote first, pay per record from $0.00009 per record.

Canonical: https://apiforagents.dev/integrations/langchain/google · Updated 2026-10-21

Call the Google API from LangChain with one HTTPS request per operation: search, news, images and shopping. Every call can be quoted free first, and you pay per record that comes back, from $0.00009 per record, from a prepaid balance with $0.10 free to start.

- Works with: LangChain
- Operations: 5
- Price: From $0.00009 per record
- Free to start: $0.10

## Set it up in LangChain

1. pip install langchain-core requests, and put your API key in AFA_KEY.
2. Give the tool to any agent; it quotes before it spends because the docstring tells it to.

## Search

python · langchain tool for Google:

```python
import os, requests
from langchain_core.tools import tool

@tool
def google_search(params: dict, estimate_only: bool = True) -> dict:
    """Search from Google. Call with estimate_only=True first and
    tell the user the price; then call again with estimate_only=False.
    Example params: {"query":"best CRM for startups","pages":1,"country":"US","language":"en"}"""
    r = requests.post(
        "https://apiforagents.dev/v1/google",
        headers={"Authorization": f"Bearer {os.environ['AFA_KEY']}"},
        json={"op": "search", **params, "estimateOnly": estimate_only},
        timeout=120,
    )
    return r.json()
```

## News

python · langchain tool for Google:

```python
import os, requests
from langchain_core.tools import tool

@tool
def google_news(params: dict, estimate_only: bool = True) -> dict:
    """News from Google. Call with estimate_only=True first and
    tell the user the price; then call again with estimate_only=False.
    Example params: {"query":"electric vehicles","postedWithin":"7d","country":"US","language":"en","limit":20}"""
    r = requests.post(
        "https://apiforagents.dev/v1/google",
        headers={"Authorization": f"Bearer {os.environ['AFA_KEY']}"},
        json={"op": "news", **params, "estimateOnly": estimate_only},
        timeout=120,
    )
    return r.json()
```

## Images

python · langchain tool for Google:

```python
import os, requests
from langchain_core.tools import tool

@tool
def google_images(params: dict, estimate_only: bool = True) -> dict:
    """Images from Google. Call with estimate_only=True first and
    tell the user the price; then call again with estimate_only=False.
    Example params: {"query":"Eiffel Tower at night","limit":20}"""
    r = requests.post(
        "https://apiforagents.dev/v1/google",
        headers={"Authorization": f"Bearer {os.environ['AFA_KEY']}"},
        json={"op": "images", **params, "estimateOnly": estimate_only},
        timeout=120,
    )
    return r.json()
```

## Shopping

python · langchain tool for Google:

```python
import os, requests
from langchain_core.tools import tool

@tool
def google_shopping(params: dict, estimate_only: bool = True) -> dict:
    """Shopping from Google. Call with estimate_only=True first and
    tell the user the price; then call again with estimate_only=False.
    Example params: {"query":"Sony WH-1000XM5","country":"US","language":"en","limit":20}"""
    r = requests.post(
        "https://apiforagents.dev/v1/google",
        headers={"Authorization": f"Bearer {os.environ['AFA_KEY']}"},
        json={"op": "shopping", **params, "estimateOnly": estimate_only},
        timeout=120,
    )
    return r.json()
```

## Google operations you can call

List prices per record. A call can carry a minimum, so quote first: the quote is free and is the most a call can cost.

| Operation | Price per record |
|---|---|
| Search | $0.0009 |
| News | $0.0018 |
| Images | $0.0009 |
| Shopping | $0.0027 |
| Play reviews | $0.00009 |

## Each operation in detail

- [Google Search API](https://apiforagents.dev/platforms/google/search-api): inputs, fields, sample, price
- [Google News API](https://apiforagents.dev/platforms/google/news-api): inputs, fields, sample, price
- [Google Images API](https://apiforagents.dev/platforms/google/images-api): inputs, fields, sample, price
- [Google Shopping API](https://apiforagents.dev/platforms/google/shopping-api): inputs, fields, sample, price
- [Google Play Reviews API](https://apiforagents.dev/platforms/google/play-store-reviews-api): inputs, fields, sample, price

## Questions

### Will the agent overspend?

Pass maxUsd in params and the API refuses any call that would cost more, before anything is spent. The balance is prepaid, so it cannot run past what was topped up.

### Does it work with LangGraph?

Yes. A LangChain tool works in create_react_agent and any LangGraph node.

### What does Google data cost?

Pay as you go, from $0.00009 per record at the list price. Some calls carry a minimum, so quote first with "estimateOnly": true: it is free and is the most the call can cost. Records that do not come back are refunded.

## Why API for Agents

- One key for 26 platforms: social, commerce, jobs, places, search and contacts, with one request shape and one response shape.
- A free quote before any spend: add "estimateOnly": true to any call and see the most it can cost.
- Pay per record in US dollars. No subscription, nothing expires, top-ups from $5.
- $0.10 free to try, no card. An AI agent can sign itself up in one request; a person claims it later.
- Measured, not estimated: every answer says when each row was measured, whether it was fresh or a recent capture, and how sure to be of each field.
- Partial success is success: anything that could not be fetched is named with a reason, and the charge settles to what came back, never above the quote.
- Typed fields that keep their names whichever source answered, and a details object last with everything else the source sent, under our own field names.
- Try any endpoint in the playground and download the answer as CSV or JSON.

## Start

The playground runs any endpoint by hand: pick a platform and what you want from it, fill a short form named in plain words (or press Use sample input), see the free quote on the Run button, run it, then read the answer as a table or JSON and download it as CSV or JSON. The same call is written out as cURL, Python and Node while you type. Open it at https://apiforagents.dev/dashboard/run?platform=google (sign in first).

Agents register at https://apiforagents.dev/auth.md (one POST, $0.10 free). People: https://apiforagents.dev/docs#start. Prices: https://apiforagents.dev/pricing.md
