Answer Results

Back to top

The area answers is an area in which additional information can be displayed.

Typification of the answer results. Results of this type are rendered in the template.


class searx.result_types.answer.BaseAnswer(*, url: str | None = None, engine: str | None = '', parsed_url: ParseResult | None = None)[source] : Bases: Result

Base class of all answer types. It is not intended to build instances of
this class (aka *abstract*).

class searx.result_types.answer.Answer(*, url: str | None = None, engine: str | None = '', parsed_url: ParseResult | None = None, template: str = 'answer/legacy.html', answer: str)[source] : Bases: BaseAnswer

Simple answer type where the *answer* is a simple string with an optional
`url field` field to link a resource (article, map, ..)
related to the answer.

answer: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
:   Text of the answer.

class searx.result_types.answer.Translations(*, url: str | None = None, engine: str | None = '', parsed_url: ParseResult | None = None, template: str = 'answer/translations.html', translations: list[Item])[source] : Bases: BaseAnswer

Answer type with a list of translations.

The items in the list of [`Translations.translations`](#searx.result_types.answer.Translations.translations) are of type
[`Translations.Item`](#searx.result_types.answer.Translations.Item):

```
def response(resp):
    results = []
    ...
    foo_1 = Translations.Item(
        text="foobar",
        synonyms=["bar", "foo"],
        examples=["foo and bar are placeholders"],
    )
    foo_url="https://www.deepl.com/de/translator#en/de/foo"
    ...
    Translations(results=results, translations=[foo], url=foo_url)
```

template: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
:   The template in

translations: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Item](#searx.result_types.answer.Translations.Item)]
:   List of translations.

class Item(*\**, *text: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*, *transliteration: [str](https://docs.python.org/3/builtins/stdtypes.html#str) = ''*, *examples: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)] = <factory>*, *definitions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)] = <factory>*, *synonyms: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)] = <factory>*)[[source]](https://docs.searxng.org/_modules/searx/result_types/answer.html#Translations.Item)
:   Bases: `Struct`

    A single element of the translations / a translation. A translation
    consists of at least a mandatory `text` property (the translation) ,
    optional properties such as *definitions*, *synonyms* and *examples* are
    possible.

    text: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
    :   Translated text.

    transliteration: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
    :   [Transliteration](https://en.wikipedia.org/wiki/Transliteration) of the requested translation.

    examples: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]
    :   List of examples for the requested translation.

    definitions: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]
    :   List of definitions for the requested translation.

    synonyms: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]
    :   List of synonyms for the requested translation.

class searx.result_types.answer.WeatherAnswer(*, url: str | None = None, engine: str | None = '', parsed_url: ParseResult | None = None, template: str = 'answer/weather.html', current: Item, forecasts: list[Item] = <factory>, service: str = '')[source] : Bases: BaseAnswer

Answer type for weather data.

template: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
:   The template is located at

current: [Item](#searx.result_types.answer.WeatherAnswer.Item)
:   Current weather at `location`.

forecasts: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Item](#searx.result_types.answer.WeatherAnswer.Item)]
:   Weather forecasts for `location`.

service: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
:   Weather service from which this information was provided.

class Item(*\**, *location: [GeoLocation](https://docs.searxng.org/src/searx.weather.html#searx.weather.GeoLocation)*, *temperature: [Temperature](https://docs.searxng.org/src/searx.weather.html#searx.weather.Temperature)*, *condition: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['clear sky', 'partly cloudy', 'cloudy', 'fair', 'fog', 'light rain and thunder', 'light rain showers and thunder', 'light rain showers', 'light rain', 'rain and thunder', 'rain showers and thunder', 'rain showers', 'rain', 'heavy rain and thunder', 'heavy rain showers and thunder', 'heavy rain showers', 'heavy rain', 'light sleet and thunder', 'light sleet showers and thunder', 'light sleet showers', 'light sleet', 'sleet and thunder', 'sleet showers and thunder', 'sleet showers', 'sleet', 'heavy sleet and thunder', 'heavy sleet showers and thunder', 'heavy sleet showers', 'heavy sleet', 'light snow and thunder', 'light snow showers and thunder', 'light snow showers', 'light snow', 'snow and thunder', 'snow showers and thunder', 'snow showers', 'snow', 'heavy snow and thunder', 'heavy snow showers and thunder', 'heavy snow showers', 'heavy snow']*, *datetime: [DateTime](https://docs.searxng.org/src/searx.weather.html#searx.weather.DateTime) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *summary: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *feels\_like: [Temperature](https://docs.searxng.org/src/searx.weather.html#searx.weather.Temperature) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *pressure: [Pressure](https://docs.searxng.org/src/searx.weather.html#searx.weather.Pressure) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *humidity: [RelativeHumidity](https://docs.searxng.org/src/searx.weather.html#searx.weather.RelativeHumidity) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *wind\_from: [Compass](https://docs.searxng.org/src/searx.weather.html#searx.weather.Compass)*, *wind\_speed: [WindSpeed](https://docs.searxng.org/src/searx.weather.html#searx.weather.WindSpeed) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*, *cloud\_cover: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None) = None*)[[source]](https://docs.searxng.org/_modules/searx/result_types/answer.html#WeatherAnswer.Item)
:   Bases: `Struct`

    Weather parameters valid for a specific point in time.

    location: [GeoLocation](https://docs.searxng.org/src/searx.weather.html#searx.weather.GeoLocation)
    :   The geo-location the weather data is from (e.g. Berlin, Germany).

    temperature: [Temperature](https://docs.searxng.org/src/searx.weather.html#searx.weather.Temperature)
    :   Air temperature at 2m above the ground.

    condition: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['clear sky', 'partly cloudy', 'cloudy', 'fair', 'fog', 'light rain and thunder', 'light rain showers and thunder', 'light rain showers', 'light rain', 'rain and thunder', 'rain showers and thunder', 'rain showers', 'rain', 'heavy rain and thunder', 'heavy rain showers and thunder', 'heavy rain showers', 'heavy rain', 'light sleet and thunder', 'light sleet showers and thunder', 'light sleet showers', 'light sleet', 'sleet and thunder', 'sleet showers and thunder', 'sleet showers', 'sleet', 'heavy sleet and thunder', 'heavy sleet showers and thunder', 'heavy sleet showers', 'heavy sleet', 'light snow and thunder', 'light snow showers and thunder', 'light snow showers', 'light snow', 'snow and thunder', 'snow showers and thunder', 'snow showers', 'snow', 'heavy snow and thunder', 'heavy snow showers and thunder', 'heavy snow showers', 'heavy snow']
    :   Standardized designations that summarize the weather situation
        (e.g. `light sleet showers and thunder`).

    datetime: [DateTime](https://docs.searxng.org/src/searx.weather.html#searx.weather.DateTime) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Time of the forecast - not needed for the current weather.

    summary: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   One-liner about the weather forecast / current weather conditions.
        If unset, a summary is build up from temperature and current weather
        conditions.

    feels\_like: [Temperature](https://docs.searxng.org/src/searx.weather.html#searx.weather.Temperature) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Apparent temperature, the temperature equivalent perceived by
        humans, caused by the combined effects of air temperature, relative
        humidity and wind speed. The measure is most commonly applied to the
        perceived outdoor temperature.

    pressure: [Pressure](https://docs.searxng.org/src/searx.weather.html#searx.weather.Pressure) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Air pressure at sea level (e.g. 1030 hPa)

    humidity: [RelativeHumidity](https://docs.searxng.org/src/searx.weather.html#searx.weather.RelativeHumidity) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Amount of relative humidity in the air at 2m above the ground. The
        unit is `%`, e.g. 60%)

    wind\_from: [Compass](https://docs.searxng.org/src/searx.weather.html#searx.weather.Compass)
    :   The directon which moves towards / direction the wind is coming from.

    wind\_speed: [WindSpeed](https://docs.searxng.org/src/searx.weather.html#searx.weather.WindSpeed) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Speed of wind / wind speed at 10m above the ground (10 min average).

    cloud\_cover: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Amount of sky covered by clouds / total cloud cover for all heights
        (cloudiness, unit: %)

    property url: [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None)
    :   Determines a [data URL](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data) with a symbol for the weather
        conditions. If no symbol can be assigned, `None` is returned.

class searx.result_types.answer.AnswerSet[source] : Bases: object

Aggregator for [`BaseAnswer`](#searx.result_types.answer.BaseAnswer) items in a result container.

Copyright © SearXNG team

Made with Furo

💾 🌐