Docs
Browse files
app.py
CHANGED
|
@@ -3,36 +3,106 @@ from camptocamp_api import CamptocampAPI
|
|
| 3 |
from typing import Tuple, Optional
|
| 4 |
|
| 5 |
|
| 6 |
-
# Instantiate API
|
| 7 |
c2c = CamptocampAPI(language="en")
|
| 8 |
|
|
|
|
| 9 |
def get_recent_outings(
|
| 10 |
-
west: float,
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
bbox = (west, south, east, north)
|
| 15 |
date_range = (start_date, end_date) if start_date and end_date else None
|
| 16 |
return c2c.get_recent_outings(bbox, date_range, activity, limit)
|
| 17 |
|
|
|
|
| 18 |
def search_routes_by_activity(
|
| 19 |
-
west: float,
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
bbox = (west, south, east, north)
|
| 23 |
return c2c.search_routes_by_activity(bbox, activity, limit)
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
return c2c.get_route_details(route_id)
|
| 27 |
|
|
|
|
| 28 |
def search_waypoints(
|
| 29 |
-
west: float,
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
bbox = (west, south, east, north)
|
| 33 |
return c2c.search_waypoints(bbox, limit)
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
| 36 |
with gr.Blocks(title="Camptocamp API MCP") as demo:
|
| 37 |
gr.Markdown("# 🏔️ Camptocamp API Interface")
|
| 38 |
|
|
|
|
| 3 |
from typing import Tuple, Optional
|
| 4 |
|
| 5 |
|
| 6 |
+
# Instantiate the Camptocamp API wrapper
|
| 7 |
c2c = CamptocampAPI(language="en")
|
| 8 |
|
| 9 |
+
|
| 10 |
def get_recent_outings(
|
| 11 |
+
west: float,
|
| 12 |
+
south: float,
|
| 13 |
+
east: float,
|
| 14 |
+
north: float,
|
| 15 |
+
start_date: Optional[str] = None,
|
| 16 |
+
end_date: Optional[str] = None,
|
| 17 |
+
activity: Optional[str] = None,
|
| 18 |
+
limit: int = 10
|
| 19 |
+
) -> dict:
|
| 20 |
+
"""
|
| 21 |
+
Get recent outings near a given location and date range.
|
| 22 |
+
|
| 23 |
+
Args:
|
| 24 |
+
west: Western longitude of the bounding box.
|
| 25 |
+
south: Southern latitude of the bounding box.
|
| 26 |
+
east: Eastern longitude of the bounding box.
|
| 27 |
+
north: Northern latitude of the bounding box.
|
| 28 |
+
start_date: Start of the date range (YYYY-MM-DD).
|
| 29 |
+
end_date: End of the date range (YYYY-MM-DD).
|
| 30 |
+
activity: Optional activity filter (e.g. "hiking", "rock_climbing").
|
| 31 |
+
limit: Number of results to return.
|
| 32 |
+
|
| 33 |
+
Returns:
|
| 34 |
+
JSON dictionary of matching outings.
|
| 35 |
+
"""
|
| 36 |
bbox = (west, south, east, north)
|
| 37 |
date_range = (start_date, end_date) if start_date and end_date else None
|
| 38 |
return c2c.get_recent_outings(bbox, date_range, activity, limit)
|
| 39 |
|
| 40 |
+
|
| 41 |
def search_routes_by_activity(
|
| 42 |
+
west: float,
|
| 43 |
+
south: float,
|
| 44 |
+
east: float,
|
| 45 |
+
north: float,
|
| 46 |
+
activity: str,
|
| 47 |
+
limit: int = 10
|
| 48 |
+
) -> dict:
|
| 49 |
+
"""
|
| 50 |
+
Search for climbing or hiking routes in a given region.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
west: Western longitude of the bounding box.
|
| 54 |
+
south: Southern latitude of the bounding box.
|
| 55 |
+
east: Eastern longitude of the bounding box.
|
| 56 |
+
north: Northern latitude of the bounding box.
|
| 57 |
+
activity: Activity type (e.g. "rock_climbing", "hiking").
|
| 58 |
+
limit: Number of routes to return.
|
| 59 |
+
|
| 60 |
+
Returns:
|
| 61 |
+
JSON dictionary of matching route metadata.
|
| 62 |
+
"""
|
| 63 |
bbox = (west, south, east, north)
|
| 64 |
return c2c.search_routes_by_activity(bbox, activity, limit)
|
| 65 |
|
| 66 |
+
|
| 67 |
+
def get_route_details(route_id: int) -> dict:
|
| 68 |
+
"""
|
| 69 |
+
Retrieve detailed route information by route ID.
|
| 70 |
+
|
| 71 |
+
Args:
|
| 72 |
+
route_id: Unique numeric ID of the route.
|
| 73 |
+
|
| 74 |
+
Returns:
|
| 75 |
+
JSON dictionary of route information including description, grade, etc.
|
| 76 |
+
"""
|
| 77 |
return c2c.get_route_details(route_id)
|
| 78 |
|
| 79 |
+
|
| 80 |
def search_waypoints(
|
| 81 |
+
west: float,
|
| 82 |
+
south: float,
|
| 83 |
+
east: float,
|
| 84 |
+
north: float,
|
| 85 |
+
limit: int = 10
|
| 86 |
+
) -> dict:
|
| 87 |
+
"""
|
| 88 |
+
Get known waypoints (e.g. huts, peaks, cols) in a given area.
|
| 89 |
+
|
| 90 |
+
Args:
|
| 91 |
+
west: Western longitude of the bounding box.
|
| 92 |
+
south: Southern latitude of the bounding box.
|
| 93 |
+
east: Eastern longitude of the bounding box.
|
| 94 |
+
north: Northern latitude of the bounding box.
|
| 95 |
+
limit: Maximum number of results.
|
| 96 |
+
|
| 97 |
+
Returns:
|
| 98 |
+
JSON dictionary of waypoints.
|
| 99 |
+
"""
|
| 100 |
bbox = (west, south, east, north)
|
| 101 |
return c2c.search_waypoints(bbox, limit)
|
| 102 |
|
| 103 |
|
| 104 |
+
# ========== Gradio UI Layer ==========
|
| 105 |
+
|
| 106 |
with gr.Blocks(title="Camptocamp API MCP") as demo:
|
| 107 |
gr.Markdown("# 🏔️ Camptocamp API Interface")
|
| 108 |
|