Skip to content

feat: add Perplexity Search API example (Python + TypeScript)#94

Open
jliounis wants to merge 1 commit into
e2b-dev:mainfrom
jliounis:feat/perplexity-search
Open

feat: add Perplexity Search API example (Python + TypeScript)#94
jliounis wants to merge 1 commit into
e2b-dev:mainfrom
jliounis:feat/perplexity-search

Conversation

@jliounis

Copy link
Copy Markdown

Summary

Adds a Perplexity Search API recipe to the cookbook, following the same pattern as the existing Firecrawl and Exa examples (third-party search/data API + E2B sandbox for analysis).

Two parallel examples are included:

  • examples/perplexity-search-js/ — TypeScript / Node, mirrors the mcp-groq-exa-js style.
  • examples/perplexity-search-python/ — Poetry project, mirrors the hello-world-python / langchain-python style.

Both call POST https://api.perplexity.ai/search directly (no extra SDK), then write the JSON results into an E2B sandbox and run a small Python snippet that prints the top domains and result snippets.

Search options exposed

  • query (required)
  • max_results (configurable, not hardcoded — defaults to the API default of 10 unless set)
  • search_domain_filter (allowlist or -domain.com denylist; not mixed)
  • search_recency_filter (hour|day|week|month|year)

Auth

Wiring

  • README: added a bullet under Example use cases linking both examples.
  • tests/examples.test.ts: registered perplexity-search-js (npm) and perplexity-search-python (poetry).
  • tests/utils.ts: added PERPLEXITY_API_KEY to the env passthrough used by the integration harness.

How to run

TypeScript:

cd examples/perplexity-search-js
cp .env.template .env  # set E2B_API_KEY and PERPLEXITY_API_KEY
npm install
npm start

Python:

cd examples/perplexity-search-python
cp .env.template .env
poetry install
poetry run start

Validation

  • TypeScript example typechecks (npx tsc --noEmit).
  • Python example parses and imports (no syntax errors).
  • Both follow the existing cookbook examples' layout so they slot into the existing tests/examples.test.ts integration harness.

Docs

Adds two examples in examples/perplexity-search-{js,python} demonstrating
how to call the Perplexity Search API and analyze results inside an E2B
sandbox.

- Auth via PERPLEXITY_API_KEY (PPLX_API_KEY also accepted)
- Helper supports query, max_results, search_domain_filter,
  search_recency_filter
- Sandbox loads results.json and prints top domains + snippets
- Wired into tests/examples.test.ts; PERPLEXITY_API_KEY added to
  tests/utils.ts env passthrough
- README updated with links to both examples
@jliounis

Copy link
Copy Markdown
Author

All checks are green and the PR has been clean since it opened. Could a maintainer take a look when you have a moment? Both the TS and Python examples follow the existing cookbook structure and exercise the Search API end-to-end via the E2B sandbox. Happy to address any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant