utils — drugs documentation

# utils

Utility helpers for HTTP requests and small collection helpers.

drugs.utils.get_json(url: str, *, params: Dict[str, object] | None = None, timeout: float = 30.0) → dict

  Fetch JSON content from an HTTP endpoint.

  Parameters:

    - url (str) – Endpoint to request.

    - params (dict, optional) – Query parameters forwarded to `requests.get`.

    - timeout (float, default=30.0) – Request timeout in seconds.

  Returns:

    Parsed JSON body from the response.

  Return type:

    dict

  Raises:

    - HTTPError – If the response status is not 2xx.

    - RuntimeError – If the content type is not JSON.

drugs.utils.dedupe_preserve_order(items: Iterable[T]) → List[T]

  Remove duplicate values while preserving input order.

  Parameters:

    items (Iterable[T]) – Items to deduplicate.

  Returns:

    List of unique items in their first-seen order.

  Return type:

    list[T]