← NeedleSearch

NeedleSearch REST API and MCP

Search private legal files in your NeedleSearch workspace. Search results include excerpts and their source document and page when available.

Create a workspace API key

Open the developer portal, sign in and create a key for the workspace you intend to search. Give the key only the permissions your integration needs. Use the key as an Authorization: Bearer header and store it on your server.

Search with the REST API

Send a POST to https://chat.needlesearch.ai/v1/search with a query and the document or folder IDs to search.

curl https://chat.needlesearch.ai/v1/search \
  -H "Authorization: Bearer $NEEDLESEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"termination notice","item_ids":["doc_YOUR_DOCUMENT_ID"],"limit":5}'

Use POST /v1/agent for a research answer with source references. The signed-in portal provides endpoint schemas, job and streaming options, and key permissions.

Search with Python

pip install needlesearchai
import os
from needlesearchai import NeedleSearch

client = NeedleSearch(api_key=os.environ["NEEDLESEARCH_API_KEY"])
response = client.search("termination notice", item_ids=["doc_YOUR_DOCUMENT_ID"], limit=5)
for result in response.results:
    print(result.document_name, result.page, result.excerpt)

Find release information and installation options on PyPI.

Connect an MCP client

Use https://chat.needlesearch.ai/mcp as the Streamable HTTP server URL. Use OAuth if your client supports it, or configure the Authorization: Bearer header with a workspace API key. The developer portal has client setup examples.

The client sends JSON-RPC requests over HTTP POST. After initialization, it can use tools/list to discover the tools its credentials can access. Calls operate within the connected workspace and the permissions granted to the connection.

Data handling

See the privacy policy for storage, hosted AI processing and on-premises options. The public ECHR Atlas is a separate research site.