The API Reference

This document will list all available APIs and their documentation (generated from the source code).


The main API for StackSearch

stacksearch.search.reverse_html(html: bs4.BeautifulSoup) → str

A more specialized version of stacksearch.reverse_markdown.generate_from_html()

stacksearch.search.search(query: str, search_on_site: str = 'stackoverflow') → Dict[str, List[str]]

Use this. This is the async version of the Search API function.

Parameters:
  • query (str) – This is the query to search the StackExchange website for.
  • search_on_site (str) – The StackExchange website to search on (the default is “stackoverflow”).
Returns:

In the format of

{
    'question': ['answer1', 'answer2', ...], 'question2': ['answer1', ...]
}

Return type:

Dict[str, List[str]]

Raises:
  • errors.RateLimitedError – You got rate limited by StackExchange
  • errors.HTMLParseError – StackExchange has changed their site structure
  • errors.RecaptchaError – StackExchange realizes that we’re a bot

A synchronous version of search for synchronous code

The errors StackSearch may raise are

exception stacksearch.errors.HTMLParseError

I couldn’t parse the HTML.

exception stacksearch.errors.RateLimitedError

We got rate limited.

exception stacksearch.errors.RecaptchaError

When StackExchange realizes we are a robot.

exception stacksearch.errors.StackSearchBaseError

The base error type for StackSearch errors.

Generate markdown from messy HTML

stacksearch.reverse_markdown.generate_from_html(html: Union[bs4.element.NavigableString, bs4.BeautifulSoup]) → str

The backend for stacksearch.search.reverse_html()

Specialized for StackExchange