Skip to main content

LangChain tools for iwant.fyi -- reference implementation of the iwant.fyi demand-side protocol v1.0. Lets any LangChain agent express structured purchase intent and receive matched supply.

Project description

iwantfyi-langchain

LangChain tools for iwant.fyi — the reference implementation of the iwant.fyi demand-side protocol v1.0.

iwant.fyi demand-side protocol is an open standard for how AI agents express structured purchase intent on behalf of users, receive matched supply across multiple sources, and report outcomes back. This package wraps iwant.fyi as a set of LangChain StructuredTool objects that any LangChain agent can use.

Install

pip install iwantfyi-langchain

Quick start

from iwantfyi_langchain import get_iwant_tools
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

tools = get_iwant_tools(api_key="iwant_ak_...")  # get a key at https://iwant.fyi

agent = create_react_agent(
    ChatOpenAI(model="gpt-4o-mini"),
    tools,
)

result = agent.invoke({
    "messages": [{"role": "user", "content": "Find me a 1/4-inch drive torque wrench under $150"}]
})
print(result["messages"][-1].content)

That's it. The agent now has seven tools wired in: demand_create_want, demand_search, demand_get_want, demand_record_outcome, demand_list_verticals, demand_list_constraints, demand_health.

Get an API key

  1. Visit iwant.fyi and sign in.
  2. Register an agent (UI or POST /api/agents).
  3. Save the returned key (format: iwant_ak_...).

What you get

Tool Spec Description
demand_create_want §8.1 Create a Want and run matching
demand_search §8.1 Ephemeral matching, no persistence
demand_get_want §8.1 Retrieve a Want by ID
demand_record_outcome §8.1 Report viewed/clicked/purchased outcome
demand_list_verticals §8.2 Discover supported verticals
demand_list_constraints §8.2 Discover constraint vocabulary
demand_health §8.2 Liveness + readiness

All tools use Pydantic v2 args schemas, so LangChain will validate user inputs before invoking iwant.fyi.

Direct client (no LangChain)

You can use the underlying IwantClient directly if you don't want LangChain in the loop:

from iwantfyi_langchain import IwantClient

with IwantClient(api_key="iwant_ak_...") as client:
    health = client.health()
    print(health["status"])

    response = client.create_want(
        title='Torque wrench, 1/4" drive, 25-100 ft-lb',
        price_cents=15000,
        vertical="tools",
        mode="any",
    )
    print(f"Want {response['want']['id']} -> {response['matches']['match_count']} matches")

Transports

By default the client uses MCP over HTTP (JSON-RPC). Switch to the REST fallback:

client = IwantClient(api_key="...", transport="http")

Both transports cover all demand.* tools. Legacy iwant.fyi tools (browse_wants, search_listings, etc.) only work over MCP transport via client.call_tool(...).

Outcome events

Outcome events feed match-quality learning and (eventually) revenue-share attribution:

client.record_outcome(want_id=w_id, match_id=m_id, event="clicked")
client.record_outcome(want_id=w_id, match_id=m_id, event="purchased", value_cents=12500)

Events are idempotent on the server side. Replays are no-ops.

Errors

Typed exceptions from iwantfyi_langchain.errors:

from iwantfyi_langchain import IwantError, UnauthorizedError, ValidationError, RateLimitedError

try:
    client.create_want(title="x", price_cents=1)
except UnauthorizedError:
    ...  # refresh key
except ValidationError as e:
    ...  # e.message, e.data
except RateLimitedError:
    ...  # back off
except IwantError as e:
    ...  # generic; e.code, e.message

Specification

Full iwant.fyi demand-side protocol v1.0 specification: iwant.fyi/protocol/v1

The protocol is published under Apache 2.0. iwant.fyi is the reference implementation; anyone may build their own.

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iwantfyi_langchain-0.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iwantfyi_langchain-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file iwantfyi_langchain-0.1.1.tar.gz.

File metadata

  • Download URL: iwantfyi_langchain-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for iwantfyi_langchain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c6033995c368d1cd5a4fbf102f62c6a6da48ad7a477f6066043c2a71781ace4e
MD5 8aa2e7e55aa966c14fbed7161a08428c
BLAKE2b-256 75789c63619b250c9b3f80b629def79c955614f2083486bbbc66ab80b3e69074

See more details on using hashes here.

File details

Details for the file iwantfyi_langchain-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for iwantfyi_langchain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c204b87ee81bc06e7800cbb97528e441d9ca47ef5c1821fd943917587b412df1
MD5 24a8f1b452aeb17e256f383b45e4ea0c
BLAKE2b-256 ef9956fc19ac978a7fb576cb7b1e73244e365e2131e8fbb342780c9701294532

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page