Skip to content

service

Camptocamp.org service for retrieving hut data.

Classes:

Functions:

Attributes:

Attributes

logger module-attribute

logger = getLogger(__name__)

service module-attribute

service = CamptocampService()

limit module-attribute

limit = 50

huts module-attribute

huts = get_huts_from_source(limit=limit)

hut module-attribute

hut = convert(hut_source, include_photos=False)

Classes

CamptocampService

CamptocampService(
    request_url: str = "https://api.camptocamp.org/waypoints",
)

Service to get huts from Camptocamp.org using their API.

Note

The methods are described in BaseService.

Classes:

Methods:

Attributes:

Attributes

support_bbox class-attribute instance-attribute
support_bbox: bool = support_bbox
support_limit class-attribute instance-attribute
support_limit: bool = support_limit
support_offset class-attribute instance-attribute
support_offset: bool = support_offset
support_convert class-attribute instance-attribute
support_convert: bool = support_convert
support_booking class-attribute instance-attribute
support_booking: bool = support_booking
request_url instance-attribute
request_url = request_url

Classes

MethodNotImplementedError
MethodNotImplementedError(obj: BaseService, method: str)

Method is not implemented exception.

Parameters:

  • obj
    (BaseService) –

    Service object (e.g. MyService).

  • method
    (str) –

    Method which is not implemented.

Functions

Functions

clear_all_cache classmethod
clear_all_cache() -> None

Clears the cache of all services!

get_huts
get_huts(
    bbox: BBox | None = None,
    limit: int = 1,
    offset: int = 0,
    include_photos: bool = True,
    **kwargs: Any,
) -> list[HutSchema]

Get all huts form source and converts them. Calls get_huts_from_source() and convert().

Returns:

  • list[HutSchema] –

    Converted huts from source.

get_bookings
get_bookings(
    date: datetime | date | Literal["now"] | None = None,
    days: int | None = None,
    source_ids: list[int | str] | None = None,
    lang: str = "de",
    request_interval: float | None = None,
    total_fallback: TotalFallback
    | Mapping[int | str, TotalFallback]
    | None = None,
) -> dict[int | str, HutBookingsSchema]

Get bookings for a list of huts.

Parameters:

  • date
    (datetime | date | Literal['now'] | None, default: None ) –

    Start daye for the bookings

  • days
    (int | None, default: None ) –

    Duration in days

  • source_ids
    (list[int | str] | None, default: None ) –

    A list of ids to return (source id, not the hut id), if set to None all are returned

  • lang
    (str, default: 'de' ) –

    Language for the response

  • request_interval
    (float | None, default: None ) –

    Interval between requests (if each huts needs a request)

  • total_fallback
    (TotalFallback | Mapping[int | str, TotalFallback] | None, default: None ) –

    Caller-provided totals that may OVERWRITE scraped page totals — a single TotalFallback for all huts or a per-hut mapping keyed by source id (int or str) / slug. Priority: booking-service total > this fallback > hut detail. Sources that publish their own totals ignore it; the field also lands in PlacesSchema.total_fallback for consumers.

Returns:

  • dict[int | str, HutBookingsSchema] –

    A dictionary with the bookings (key = source id).

get_huts_from_source
get_huts_from_source(
    bbox: BBox | None = None,
    limit: int = 100,
    offset: int = 0,
    fetch_details: bool = True,
    request_interval: float = 0.5,
    **kwargs: Any,
) -> list[CamptocampHutSource]

Get huts from Camptocamp API.

Parameters:

  • bbox
    (BBox | None, default: None ) –

    Bounding box for geographic filtering

  • limit
    (int, default: 100 ) –

    Maximum number of results

  • offset
    (int, default: 0 ) –

    Offset for pagination

  • fetch_details
    (bool, default: True ) –

    Whether to fetch detailed information for each hut

  • request_interval
    (float, default: 0.5 ) –

    Delay in seconds between detail requests (to be nice to the API)

  • **kwargs
    (Any, default: {} ) –

    Additional parameters

Returns:

convert
convert(
    src: Mapping | Any, include_photos: bool = True
) -> HutSchema

Convert CamptocampHutSource to HutSchema.

Parameters:

  • src
    (Mapping | Any) –

    Source data (CamptocampHutSource or dict)

  • include_photos
    (bool, default: True ) –

    Whether to include photos

Returns:

Functions

camptocamp_detail_request

camptocamp_detail_request(
    url: str, document_id: int, **params: Any
) -> CamptocampDocument | None

Request detailed information for a specific hut from Camptocamp API.

Parameters:

  • url

    (str) –

    Base API URL (without document ID)

  • document_id

    (int) –

    The document ID to fetch

  • **params

    (Any, default: {} ) –

    Additional query parameters

Returns:

  • CamptocampDocument | None –

    CamptocampDocument with detailed information or None if failed

camptocamp_request

camptocamp_request(
    url: str,
    waypoint_type: str = "hut",
    limit: int | None = None,
    offset: int = 0,
    bbox: BBox | None = None,
    **params: Any,
) -> CamptocampApiResponse

Request huts from Camptocamp API.

Parameters:

  • url

    (str) –

    Base API URL

  • waypoint_type

    (str, default: 'hut' ) –

    Type of waypoint to fetch (default: "hut")

  • limit

    (int | None, default: None ) –

    Maximum number of results

  • offset

    (int, default: 0 ) –

    Offset for pagination

  • bbox

    (BBox | None, default: None ) –

    Bounding box for geographic filtering

  • **params

    (Any, default: {} ) –

    Additional query parameters

Returns: