VOOZH about

URL: https://pypi.org/project/ddgs/

⇱ ddgs Β· PyPI


Skip to main content

ddgs 9.14.4

pip install ddgs

Latest release

Released:

Dux Distributed Global Search. A metasearch library that aggregates results from diverse web search services.

Navigation

Verified details

These details have been verified by PyPI
Maintainers
πŸ‘ Avatar for deedy5 from gravatar.com
deedy5

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License Expression: MIT
    SPDX License Expression
  • Author: deedy5
  • Tags python , search , metasearch
  • Requires: Python >=3.10
  • Provides-Extra: dev , mcp , api , dht

Project description

πŸ‘ Python >= 3.10
πŸ‘ Image
πŸ‘ Image

DDGS | Dux Distributed Global Search

A metasearch library that aggregates results from diverse web search services.

Table of Contents


Install

pip install -U ddgs # Base install
pip install -U ddgs[api] # API server (FastAPI)
pip install -U ddgs[mcp] # MCP server (stdio)

CLI version

ddgs --help

Go To TOP


API Server

-- Install

pipinstall-Uddgs[api]

-- CLI

ddgsapi# Start server in foreground
ddgsapi-d# Start in detached mode (background)
ddgsapi-s# Stop detached server
ddgsapi--host127.0.0.1--port4479# Default port 4479
ddgsapi-prsocks5h://127.0.0.1:9150# With proxy

-- Docker compose

gitclonehttps://github.com/deedy5/ddgs&&cdddgs
docker-composeup--build

-- Bash script

gitclonehttps://github.com/deedy5/ddgs&&cdddgs
chmod+xstart_api.sh
./start_api.sh

Endpoints

Endpoint Method Description
/search/text GET, POST Text search
/search/images GET, POST Image search
/search/news GET, POST News search
/search/videos GET, POST Video search
/search/books GET, POST Book search
/extract GET, POST Extract content from URL
/health GET Health check
/docs GET Swagger UI
/redoc GET ReDoc documentation

Go To TOP


DHT Network (BETA)

DDGS includes an optional peer-to-peer distributed cache network. Search results are shared anonymously between users, drastically reducing rate limits and latency for everyone.

This is the only metasearch engine that can actually get faster the more people use it.


Why this exists

Every DDGS user currently hits search engines independently. Everyone gets rate limited individually. Everyone waits 1-2 seconds for exactly the same results.

The DHT network fixes this:

  • βœ… 90% faster repeated queries (50ms instead of 1-2s)
  • βœ… No rate limits for common queries
  • βœ… Zero infrastructure cost - runs entirely on user machines
  • βœ… No central server - cannot be blocked or shut down
  • βœ… Anonymous - no one sees your queries, no logs

How it works

When running:

  1. Your node automatically discovers other DDGS users
  2. All existing API endpoints automatically check the network first
  3. If found, returns results immediately
  4. If not, searches normally and shares the result anonymously
  5. Every new user makes the network faster for everyone else

Installation

# Install base DHT package
pipinstall-Uddgs[dht]

# Install required dependencies (works on Linux and macOS)
pipinstallcoincurve@git+https://github.com/ofek/coincurve.git@7829b29c08ebb1cc80386a1cdaf8c2243c4ef5c5
pipinstalllibp2p@git+https://github.com/libp2p/py-libp2p.git@0e88584c89377086883c6f5b26cd1a8052399be7

# macOS only: First install gmp
brewinstallgmp

# Windows: DHT is not supported. Use base package only.

When installed, DHT:

  • Adds persistent local result cache
  • Adds /dht/* endpoints to the API server automatically
  • Starts full distributed network node when you run ddgs api
  • Works fully transparently - all existing search methods automatically use cache

Platform Support: DHT works on Linux and macOS. Windows is not currently supported due to libp2p dependencies.

Running

  1. Using terminal
ddgsapi-d
  1. Using DDGS initialization
fromddgsimport DDGS

ddgs = DDGS(api_url="http://localhost:4479", spawn_api=True)

You do not need to change any existing code. Any Python script using DDGS().text(), images(), etc. will automatically use both the local cache and the distributed DHT network.

DHT will automatically start in the background and begin participating in the network.

DHT API Endpoints

Endpoint Method Description
/dht/cache GET Get cached results
/dht/cache POST Store results to cache
/dht/cache DELETE Invalidate cached results
/dht/status GET DHT service status and metrics
/dht/peers GET List connected peers
/dht/peers/detailed GET Detailed peer information
/dht/map GET Network graph view
/dht/metrics GET Prometheus format metrics

Beta Status

This is working beta software. All functionality is complete, but network performance will improve as more users join:

Network Size Performance
< 50 nodes Marginal - expect timeouts
50-200 nodes Good - >95% success rate
>200 nodes Excellent - near perfect

Results use eventual consistency and may take 1-5 minutes to propagate.

Please report any issues here: https://github.com/deedy5/ddgs/issues

Go To TOP


MCP Server

  • Install
pipinstall-Uddgs[mcp]
  • CLI
ddgsmcp# Start MCP server (stdio transport)
ddgsmcp-prsocks5h://127.0.0.1:9150# With proxy

Available Tools

Tool Description
search_text Web text search
search_images Image search
search_news News search
search_videos Video search
search_books Book search
extract_content Extract content from a URL

Client Configuration

For MCP clients like Cursor or Claude Desktop:

{
"mcpServers":{
"ddgs":{
"command":"ddgs",
"args":["mcp"]
}
}
}

Go To TOP


Engines

DDGS function Available backends
text() bing, brave, duckduckgo, google, grokipedia, mojeek, startpage, yandex, yahoo, wikipedia
images() bing, duckduckgo
videos() duckduckgo
news() bing, duckduckgo, yahoo
books() annasarchive

Go To TOP

DDGS class

DDGS class is lazy-loaded.

classDDGS:
"""Dux Distributed Global Search. A metasearch library that aggregates results from diverse web search services.

 Args:
 proxy (str, optional): proxy for the HTTP client, supports http/https/socks5 protocols.
 example: "http://user:pass@example.com:3128". Defaults to None.
 timeout (int, optional): Timeout value for the HTTP client. Defaults to 5.
 verify: (bool | str): True to verify, False to skip, or a str path to a PEM file. Defaults to True.
 """

Here is an example of initializing the DDGS class.

fromddgsimport DDGS

results = DDGS().text("python programming", max_results=5)
print(results)

Go To TOP

1. text()

deftext(
 query: str,
 region: str = "us-en",
 safesearch: str = "moderate",
 timelimit: str | None = None,
 max_results: int | None = 10,
 page: int = 1,
 backend: str = "auto",
) -> list[dict[str, str]]:
"""DDGS text metasearch.

 Args:
 query: text search query.
 region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
 safesearch: on, moderate, off. Defaults to "moderate".
 timelimit: d, w, m, y. Defaults to None.
 max_results: maximum number of results. Defaults to 10.
 page: page of results. Defaults to 1.
 backend: A single or comma-delimited backends. Defaults to "auto".

 Returns:
 List of dictionaries with search results.
 """

Example

results = DDGS().text("live free or die", region="us-en", safesearch="off", timelimit="y", page=1, backend="auto")
# Searching for pdf files
results = DDGS().text("russia filetype:pdf", region="us-en", safesearch="off", timelimit="y", page=1, backend="auto")
print(results)
[
 {
 "title": "News, sport, celebrities and gossip | The Sun",
 "href": "https://www.thesun.co.uk/",
 "body": "Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The Sun",
 },
 ...,
]

Go To TOP

2. images()

defimages(
 query: str,
 region: str = "us-en",
 safesearch: str = "moderate",
 timelimit: str | None = None,
 max_results: int | None = 10,
 page: int = 1,
 backend: str = "auto",
 size: str | None = None,
 color: str | None = None,
 type_image: str | None = None,
 layout: str | None = None,
 license_image: str | None = None,
) -> list[dict[str, str]]:
"""DDGS images metasearch.

 Args:
 query: images search query.
 region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
 safesearch: on, moderate, off. Defaults to "moderate".
 timelimit: d, w, m, y. Defaults to None.
 max_results: maximum number of results. Defaults to 10.
 page: page of results. Defaults to 1.
 backend: A single or comma-delimited backends. Defaults to "auto".
 size: Small, Medium, Large, Wallpaper. Defaults to None.
 color: color, Monochrome, Red, Orange, Yellow, Green, Blue,
 Purple, Pink, Brown, Black, Gray, Teal, White. Defaults to None.
 type_image: photo, clipart, gif, transparent, line.
 Defaults to None.
 layout: Square, Tall, Wide. Defaults to None.
 license_image: any (All Creative Commons), Public (PublicDomain),
 Share (Free to Share and Use), ShareCommercially (Free to Share and Use Commercially),
 Modify (Free to Modify, Share, and Use), ModifyCommercially (Free to Modify, Share, and
 Use Commercially). Defaults to None.

 Returns:
 List of dictionaries with images search results.
 """

Example

results = DDGS().images(
 query="butterfly",
 region="us-en",
 safesearch="off",
 timelimit="m",
 page=1,
 backend="auto",
 size=None,
 color="Monochrome",
 type_image=None,
 layout=None,
 license_image=None,
)
print(images)
[
 {
 "title": "File:The Sun by the Atmospheric Imaging Assembly of NASA's Solar ...",
 "image": "https://upload.wikimedia.org/wikipedia/commons/b/b4/The_Sun_by_the_Atmospheric_Imaging_Assembly_of_NASA's_Solar_Dynamics_Observatory_-_20100819.jpg",
 "thumbnail": "https://tse4.mm.bing.net/th?id=OIP.lNgpqGl16U0ft3rS8TdFcgEsEe&pid=Api",
 "url": "https://en.wikipedia.org/wiki/File:The_Sun_by_the_Atmospheric_Imaging_Assembly_of_NASA's_Solar_Dynamics_Observatory_-_20100819.jpg",
 "height": 3860,
 "width": 4044,
 "source": "Bing",
 },
 ...,
]

Go To TOP

3. videos()

defvideos(
 query: str,
 region: str = "us-en",
 safesearch: str = "moderate",
 timelimit: str | None = None,
 max_results: int | None = 10,
 page: int = 1,
 backend: str = "auto",
 resolution: str | None = None,
 duration: str | None = None,
 license_videos: str | None = None,
) -> list[dict[str, str]]:
"""DDGS videos metasearch.

 Args:
 query: videos search query.
 region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
 safesearch: on, moderate, off. Defaults to "moderate".
 timelimit: d, w, m. Defaults to None.
 max_results: maximum number of results. Defaults to 10.
 page: page of results. Defaults to 1.
 backend: A single or comma-delimited backends. Defaults to "auto".
 resolution: high, standart. Defaults to None.
 duration: short, medium, long. Defaults to None.
 license_videos: creativeCommon, youtube. Defaults to None.

 Returns:
 List of dictionaries with videos search results.
 """

Example

results = DDGS().videos(
 query="cars",
 region="us-en",
 safesearch="off",
 timelimit="w",
 page=1,
 backend="auto",
 resolution="high",
 duration="medium",
)
print(results)
[
 {
 "content": "https://www.youtube.com/watch?v=6901-C73P3g",
 "description": "Watch the Best Scenes of popular Tamil Serial #Meena that airs on Sun TV. Watch all Sun TV serials immediately after the TV telecast on Sun NXT app. *Free for Indian Users only Download here: Android - http://bit.ly/SunNxtAdroid iOS: India - http://bit.ly/sunNXT Watch on the web - https://www.sunnxt.com/ Two close friends, Chidambaram ...",
 "duration": "8:22",
 "embed_html": '<iframe width="1280" height="720" src="https://www.youtube.com/embed/6901-C73P3g?autoplay=1" frameborder="0" allowfullscreen></iframe>',
 "embed_url": "https://www.youtube.com/embed/6901-C73P3g?autoplay=1",
 "image_token": "6c070b5f0e24e5972e360d02ddeb69856202f97718ea6c5d5710e4e472310fa3",
 "images": {
 "large": "https://tse4.mm.bing.net/th?id=OVF.JWBFKm1u%2fHd%2bz2e1GitsQw&pid=Api",
 "medium": "https://tse4.mm.bing.net/th?id=OVF.JWBFKm1u%2fHd%2bz2e1GitsQw&pid=Api",
 "motion": "",
 "small": "https://tse4.mm.bing.net/th?id=OVF.JWBFKm1u%2fHd%2bz2e1GitsQw&pid=Api",
 },
 "provider": "Bing",
 "published": "2024-07-03T05:30:03.0000000",
 "publisher": "YouTube",
 "statistics": {"viewCount": 29059},
 "title": "Meena - Best Scenes | 02 July 2024 | Tamil Serial | Sun TV",
 "uploader": "Sun TV",
 },
 ...,
]

Go To TOP

4. news()

defnews(
 query: str,
 region: str = "us-en",
 safesearch: str = "moderate",
 timelimit: str | None = None,
 max_results: int | None = 10,
 page: int = 1,
 backend: str = "auto",
) -> list[dict[str, str]]:
"""DDGS news metasearch.

 Args:
 query: news search query.
 region: us-en, uk-en, ru-ru, etc. Defaults to us-en.
 safesearch: on, moderate, off. Defaults to "moderate".
 timelimit: d, w, m. Defaults to None.
 max_results: maximum number of results. Defaults to 10.
 page: page of results. Defaults to 1.
 backend: A single or comma-delimited backends. Defaults to "auto".

 Returns:
 List of dictionaries with news search results.
 """

Example

results = DDGS().news(query="sun", region="us-en", safesearch="off", timelimit="m", page=1, backend="auto")
print(results)
[
 {
 "date": "2024-07-03T16:25:22+00:00",
 "title": "Murdoch's Sun Endorses Starmer's Labour Day Before UK Vote",
 "body": "Rupert Murdoch's Sun newspaper endorsed Keir Starmer and his opposition Labour Party to win the UK general election, a dramatic move in the British media landscape that illustrates the country's shifting political sands.",
 "url": "https://www.msn.com/en-us/money/other/murdoch-s-sun-endorses-starmer-s-labour-day-before-uk-vote/ar-BB1plQwl",
 "image": "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/BB1plZil.img?w=2000&h=1333&m=4&q=79",
 "source": "Bloomberg on MSN.com",
 },
 ...,
]

Go To TOP

5. books()

defbooks(
 query: str,
 max_results: int | None = 10,
 page: int = 1,
 backend: str = "auto",
) -> list[dict[str, str]]:
"""DDGS books metasearch.

 Args:
 query: news search query.
 max_results: maximum number of results. Defaults to 10.
 page: page of results. Defaults to 1.
 backend: A single or comma-delimited backends. Defaults to "auto".

 Returns:
 List of dictionaries with news search results.
 """

Example

results = DDGS().books(query="sea wolf jack london", page=1, backend="auto")
print(results)
[
 {
 "title": "The Sea-Wolf",
 "author": "Jack London",
 "publisher": "DigiCat, 2022",
 "info": "English [en], .epub, πŸš€/zlib, 0.5MB, πŸ“— Book (unknown)",
 "url": "https://annas-archive.li/md5/574f6556f1df6717de4044e36c7c2782",
 "thumbnail": "https://s3proxy.cdn-zlib.sk//covers299/collections/userbooks/da4954486be7c2b2b9f70b2aa5bcf01292de3ea510b5656f892821950ded9ada.jpg",
 },
 ...,
]

Go To TOP

6. extract()

Fetch a URL and extract its content in various formats.

defextract(
 url: str,
 fmt: str = "text_markdown",
) -> dict[str, str | bytes]:
"""Fetch a URL and extract its content.

 Args:
 url: The URL to fetch and extract content from.
 fmt: Output format:
 "text_markdown" (HTML→Markdown, preserves links/headers/lists),
 "text_plain" (HTML→plain text),
 "text_rich" (HTML→rich text with headers/lists),
 "text" (raw HTML),
 "content" (raw bytes).

 Returns:
 Dictionary with 'url' and 'content' keys.
 """

Examples

# Markdown (default) - preserves links, headers, lists
result = DDGS().extract("https://example.com")
print(result)
{"url": "https://example.com", "content": "# Example Domain\n\nThis domain is for use in..."}

# Plain text
result = DDGS().extract("https://example.com", fmt="text_plain")

# Rich text (headers/lists, no link URLs)
result = DDGS().extract("https://example.com", fmt="text_rich")

# Raw HTML
result = DDGS().extract("https://example.com", fmt="text")

# Raw bytes
result = DDGS().extract("https://example.com", fmt="content")

CLI

ddgsextract-uhttps://example.com
ddgsextract-uhttps://example.com-ftext_plain
ddgsextract-uhttps://example.com-fcontent-ooutput.json

Go To TOP

Disclaimer

This library is for educational purposes only.

Project details

Verified details

These details have been verified by PyPI
Maintainers
πŸ‘ Avatar for deedy5 from gravatar.com
deedy5

Unverified details

These details have not been verified by PyPI
Project links
Meta
  • License Expression: MIT
    SPDX License Expression
  • Author: deedy5
  • Tags python , search , metasearch
  • Requires: Python >=3.10
  • Provides-Extra: dev , mcp , api , dht

Release history Release notifications | RSS feed

Download files

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

Source Distribution

ddgs-9.14.4.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

Filter files by name, interpreter, ABI, and platform.

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

Copy a direct link to the current filters

ddgs-9.14.4-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

Details for the file ddgs-9.14.4.tar.gz.

File metadata

  • Download URL: ddgs-9.14.4.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ddgs-9.14.4.tar.gz
Algorithm Hash digest
SHA256 f7b118a2b709a9e9c04a1dca6e96b98c25d4dfaca1a4b0a244d74454fcca48ef
MD5 3bd234dde1fc361bcebb378322f2a62c
BLAKE2b-256 77249d29eeb7dd4852c27c3673adcaf30c4dc55ced76b303c1fbb792ce7cae52

See more details on using hashes here.

File details

Details for the file ddgs-9.14.4-py3-none-any.whl.

File metadata

  • Download URL: ddgs-9.14.4-py3-none-any.whl
  • Upload date:
  • Size: 70.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ddgs-9.14.4-py3-none-any.whl
Algorithm Hash digest
SHA256 acb084c34bf1110c974caf7e5e5a2c1973beb4bd9e170bfd191fe5ed2d2b2d6c
MD5 0f6b34982d27c2c1c6ad59f53a56231e
BLAKE2b-256 e85f32de4d99220eb559b7b1cd1c529a1856efa8097f7a3e10b6c207aa95e36c

See more details on using hashes here.

Supported by

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