Skip to main content

NimbleSearchRetriever

NimbleSearchRetriever enables developers to build RAG applications and AI Agents that can search, access, and retrieve online information from anywhere on the web. NimbleSearchRetriever harnesses Nimble’s Data APIs to execute search queries and retrieve web data in an efficient, scalable, and effective fashion. It has two modes:
  • Search & Retrieve: Execute a search query, get the top result URLs, and retrieve the text from those URLs.
  • Retrieve: Provide a list of URLs, and retrieve the text/data from those URLs.
If you’d like to learn more about the underlying Nimble APIs, visit the documentation here.

Setup

To begin using NimbleSearchRetriever, you’ll first need to open an account with Nimble and subscribe to a plan. Nimble offers free trials, which you can register for here. For more information about available plans, see our Pricing page. Once you have registered, you will need to enter the “Nimble API” pipeline in the “Pipelines” page which will provide you with your API credentials (as a base64 token) that you will use to authenticate your retriever: example-image Now, you can set your credential string as an environment variable so NimbleSearchRetriever will capture it automatically without having to pass it each time inline.
For more information about the Authentication process, see Nimble APIs Authentication Documentation. If you want to get automated tracing for individual queries, you can set your LangSmith API key by uncommenting below:

Installation

The retriever is part of langchain providers which is included in the langchain-nimble package available on pypi.

Instantiation

Now we can instantiate our retriever:

Usage

NimbleSearchRetriever has these arguments:
  • k (optional) integer - Number of results to return (less than or equal to 20)
  • api_key (optional) string - Nimble’s API key, can be sent directly when instantiating the retriever or with the environment variable (NIMBLE_API_KEY)
  • search_engine (optional) string - The search engine your query will be executed through, you can choose from
    • google_search (default value) - Google’s search engine
    • bing_search - Bing’s search engine
    • yandex_search - Yandex search engine
  • render (optional) boolean - Enables or disables Javascript rendering on the target page (if enabled the results might return more slowly)
  • locale (optional) string - LCID standard locale used for the URL request. Alternatively, user can use auto for automatic locale based on country targeting.
  • country (optional) string - Country used to access the target URL, use ISO Alpha-2 Country Codes i.e. US, DE, GB
  • parsing_type (optional) string - The text structure of the returned page_content
    • plain_text (default value) - Extracts just the text from the html
    • markdown - Markdown format
    • simplified_html - Compressed version of the original html document (~8% of the orignial html size)
  • links (optional) Array of strings - Array of links to the requested websites to scrape, if chosen will return the raw html content from these html (THIS WILL ACTIVATE THE SECOND MODE)
You can read more about each argument in Nimble’s docs.

Example of search & retrieve mode with a search query string

Fetching a single document will result in the following:
While invoking the same query without taking just one document will result with:

Example of retrieval mode with an array of URLs

Use within a chain

Like other retrievers, NimbleSearchRetriever can be incorporated into LLM applications via chains. We will need an LLM or chat model: