### Install PyForks via pip Source: https://pyforks.mn-mtb.com/getting_started.html Use this command to install the library from PyPi. ```bash pip install pyforks ``` -------------------------------- ### Get Trail Information Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Retrieves details for a specific trail by its ID. ```python from PyForks import Trails trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') trail_id = 12345 trail_api.get_trail(trail_id) ``` -------------------------------- ### Get Event Information Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Retrieves details for a specific event by its ID. ```python from PyForks import Events event_api = Events(app_id='your_app_id', app_secret='your_app_secret') event_id = 12345 event_api.get_event(event_id) ``` -------------------------------- ### Get Events by Region Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Retrieves a list of events for a specific region. ```python from PyForks import Events event_api = Events(app_id='your_app_id', app_secret='your_app_secret') args = {"filter": "rid::3203"} # Minnesota Region event_api.get_events(**args) # Get all events for the Minnesota region ``` -------------------------------- ### Get Events by Region Source: https://pyforks.mn-mtb.com/examples.html Retrieves all events scheduled within a specific region. ```python 1from PyForks import Events 2 3event_api = Events(app_id='your_app_id', app_secret='your_app_secret') 4args = {"filter": "rid::3203"} # Minnesota Region 5event_api.get_events(**args) # Get all events for the Minnesota region ``` -------------------------------- ### Get Event Information Source: https://pyforks.mn-mtb.com/examples.html Retrieves details for a specific event using its unique ID. ```python 1from PyForks import Events 2 3event_api = Events(app_id='your_app_id', app_secret='your_app_secret') 4event_id = 12345 5event_api.get_event(event_id) ``` -------------------------------- ### Get Trail Status Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Fetches and prints the status of a specific trail. ```python from PyForks import Trails from PyForks.lookups import trail_status_short trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') trail_id = 12345 trail_status = trail_api.get_trail_status(trail_id) status_int = response.get("data", {}).get("updates", {}).get("trails_info", {}).get("rows", [[]])[0][1] print(trail_status_short.get(status_int)) ``` -------------------------------- ### Get Trail Information Source: https://pyforks.mn-mtb.com/examples.html Retrieves specific information for a single trail using its unique ID. ```python 1from PyForks import Trails 2 3trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') 4trail_id = 12345 5trail_api.get_trail(trail_id) ``` -------------------------------- ### Get Trail Status Source: https://pyforks.mn-mtb.com/examples.html Fetches the current status of a specific trail and prints the short status code. ```python 1from PyForks import Trails 2from PyForks.lookups import trail_status_short 3 4trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') 5trail_id = 12345 6trail_status = trail_api.get_trail_status(trail_id) 7status_int = response.get("data", {}).get("updates", {}).get("trails_info", {}).get("rows", [[]])[0][1] 8print(trail_status_short.get(status_int)) ``` -------------------------------- ### Get Trails by Region Source: https://pyforks.mn-mtb.com/examples.html Retrieves a list of all trails associated with a specific region ID. ```python 1from PyForks import Trails 2 3trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') 4args = {"filter": "rid::20367"} # Minnesota Region 5trail_api.get_trails(**args) # Get all trails for the Minnesota region ``` -------------------------------- ### Get Trails by Region Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Retrieves a list of trails associated with a specific region ID. ```python from PyForks import Trails trail_api = Trails(app_id='your_app_id', app_secret='your_app_secret') args = {"filter": "rid::20367"} # Minnesota Region trail_api.get_trails(**args) # Get all trails for the Minnesota region ``` -------------------------------- ### Get Region Information Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Retrieves information for a specific region using a filter parameter. ```python from PyForks import Regions region_api = Regions(app_id='your_app_id', app_secret='your_app_secret') params = {'filter': 'rid::12345'} region_api.get_region(**params) ``` -------------------------------- ### Get Region Information Source: https://pyforks.mn-mtb.com/examples.html Retrieves details for a specific region using a filter parameter. ```python 1from PyForks import Regions 2 3region_api = Regions(app_id='your_app_id', app_secret='your_app_secret') 4params = {'filter': 'rid::12345'} 5region_api.get_region(**params) ``` -------------------------------- ### Get Region Status Source: https://pyforks.mn-mtb.com/_sources/examples.rst.txt Fetches the status of a region since a specific timestamp and parses the returned data. ```python from PyForks import Regions from PyForks.lookups import trail_status_short from datetime import datetime import time regions = Regions(app_id=app_id, app_secret=app_secret) # Create a new instance of the Regions class date_obj = datetime.strptime("2022-01-01", "%Y-%m-%d") # Create a datetime object since_timestamp = int(time.mktime(date_obj.timetuple())) # Convert the datetime object to a timestamp args = {"rids": west_lake_marion_id} # Create a dictionary of arguments to pass to the get_region_status method region_status = regions.get_region_status(since_timestamp, **args) # Columns: id,status,condition,status_ts,last_report_ts,changed columns = region_status.get("data", {}).get("updates", {}).get("regions_info", {}).get("columns", []) rows = region_status.get("data", {}).get("updates", {}).get("regions_info", {}).get("rows", []) for row in rows: print(trail_status_short.get(row[1])) print(trail_status.get(row[1])) ``` -------------------------------- ### Get Region Status Source: https://pyforks.mn-mtb.com/examples.html Fetches status updates for a region since a specific timestamp, requiring the Regions class and status lookup utilities. ```python 1from PyForks import Regions 2from PyForks.lookups import trail_status_short 3from datetime import datetime 4import time 5 6regions = Regions(app_id=app_id, app_secret=app_secret) # Create a new instance of the Regions class 7 8date_obj = datetime.strptime("2022-01-01", "%Y-%m-%d") # Create a datetime object 9since_timestamp = int(time.mktime(date_obj.timetuple())) # Convert the datetime object to a timestamp 10args = {"rids": west_lake_marion_id} # Create a dictionary of arguments to pass to the get_region_status method 11 12region_status = regions.get_region_status(since_timestamp, **args) 13# Columns: id,status,condition,status_ts,last_report_ts,changed 14columns = region_status.get("data", {}).get("updates", {}).get("regions_info", {}).get("columns", []) 15rows = region_status.get("data", {}).get("updates", {}).get("regions_info", {}).get("rows", []) 16 17for row in rows: 18 print(trail_status_short.get(row[1])) 19 print(trail_status.get(row[1])) ``` -------------------------------- ### Report trail status using PyForks Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Submits a trail report with status and optional parameters like condition, description, and marker. ```python data = {'trailid': trailid, 'status': status} data.update(kwargs) response = self.trailforks_session.post(f"{self.base_uri}/report", data=data) return response.json() ``` -------------------------------- ### Retrieve trail reports using PyForks Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Fetches a list of reports with optional filtering, sorting, and pagination parameters. ```python def get_reports(self, **kwargs) -> Dict[str, Any]: """ Return a list of reports. Args: **kwargs: Optional parameters such as: scope (str): Detail level of report object to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of reports to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/reports", params=kwargs) return response.json() ``` -------------------------------- ### Retrieve supporters for trails, regions, or routes Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Fetches a list of supporters associated with specific entities, supporting pagination and field filtering. ```python def get_supporters(self, **kwargs) -> Dict[str, Any]: """ Return a list of supporters for a trail, region, or route. Args: **kwargs: Optional parameters such as: fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of supporters to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/supporters", params=kwargs) return response.json() ``` -------------------------------- ### Events(app_id, app_secret, debug) Source: https://pyforks.mn-mtb.com/PyForks.html Initializes the Events client to interact with the Trailforks API. ```APIDOC ## Events(app_id, app_secret, debug) ### Description Initializes the client for accessing event-related data from the Trailforks API. ### Parameters - **app_id** (str) - Optional - Application ID. - **app_secret** (str) - Optional - Application Secret. - **debug** (bool) - Optional - Enable debug mode. ``` -------------------------------- ### get_videos Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of trail or region videos. ```APIDOC ## get_videos(**kwargs) ### Description Returns a list of trail or region videos. ### Parameters - **scope** (str) - Optional - Detail level of video objects to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of videos to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### Retrieve lists of public routes Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Fetches a collection of public routes with support for filtering, sorting, and pagination. ```python def get_routes(self, **kwargs) -> Dict[str, Any]: """ Return a list of public routes. Args: **kwargs: Optional parameters such as: scope (str): Detail level of route object to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of routes to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/routes", params=kwargs) return response.json() ``` -------------------------------- ### Retrieve trail or region media Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Fetches lists of videos or photos for trails or regions, with options for scope, filtering, and pagination. ```python def get_videos(self, **kwargs) -> Dict[str, Any]: """ Return a list of trail or region videos. Args: **kwargs: Optional parameters such as: scope (str): Detail level of video objects to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of videos to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/videos", params=kwargs) return response.json() ``` ```python def get_photos(self, **kwargs) -> Dict[str, Any]: """ Return a list of trail or region photos. Args: **kwargs: Optional parameters such as: scope (str): Detail level of photo objects to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of photos to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/photos", params=kwargs) return response.json() ``` -------------------------------- ### get_routes Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of public routes. ```APIDOC ## get_routes(**kwargs) ### Description Returns a list of public routes with optional filtering and pagination. ### Parameters - **scope** (str) - Optional - Detail level of route object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of routes to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### get_supporters Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of supporters for a trail, region, or route. ```APIDOC ## get_supporters(**kwargs) ### Description Returns a list of supporters for a trail, region, or route. ### Parameters - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of supporters to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### Access API Enums Source: https://pyforks.mn-mtb.com/getting_started.html Reference the lookups module for dictionaries mapping API integer values to human-readable strings. ```python trail_conditions = { 0: "Unknown", 1: "Snow Packed", 2: "Prevalent Mud", 3: "Wet", 4: "Variable", 5: "Dry", 6: "Very Dry", 7: "Snow Covered", 8: "Freeze/thaw Cycle", 9: "Icy", 10: "Snow Groomed", 11: "Ideal", 12: "Snow Cover Partial" } difficulty_short = { 1: "Access Road/Trail", 2: "White", 3: "Green", 4: "Blue", 5: "Black", 6: "Double Black Diamond", 7: "Secondary Access Road/Trail", 8: "Proline", 12: "Lift" } ``` -------------------------------- ### Regions.get_supporters Source: https://pyforks.mn-mtb.com/PyForks.html Retrieves a list of supporters for a trail, region, or route. ```APIDOC ## get_supporters(**kwargs) ### Description Return a list of supporters for a trail, region, or route. ### Parameters - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of supporters to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Response - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### Retrieve a list of events Source: https://pyforks.mn-mtb.com/_modules/PyForks/events.html Fetches a collection of events with support for filtering, pagination, and sorting parameters. ```python def get_events(self, **kwargs) -> Dict[str, Any]: """ Return a list of events. Args: **kwargs: Optional parameters such as: scope (str): Detail level of event object to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of events to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/events", params=kwargs) return response.json() ``` -------------------------------- ### get_route Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a specific route by its ID. ```APIDOC ## get_route(id: int, **kwargs) ### Description Returns a specific route based on the provided ID. ### Parameters - **id** (int) - Required - ID of the route. - **scope** (str) - Optional - Detail of route object to return. - **fields** (str) - Optional - Limit the fields returned. ``` -------------------------------- ### get_photos Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of trail or region photos. ```APIDOC ## get_photos(**kwargs) ### Description Returns a list of trail or region photos. ### Parameters - **scope** (str) - Optional - Detail level of photo objects to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of photos to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### Regions.get_videos Source: https://pyforks.mn-mtb.com/PyForks.html Retrieves a list of trail or region videos with optional filtering and pagination. ```APIDOC ## get_videos(**kwargs) ### Description Return a list of trail or region videos. ### Parameters - **scope** (str) - Optional - Detail level of video objects to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of videos to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Response - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### PyForks.utilities.feet_to_miles Source: https://pyforks.mn-mtb.com/PyForks.html Converts a distance in feet to miles. ```APIDOC ## feet_to_miles(feet: int) -> float ### Description Translates feet into miles. ### Parameters - **feet** (int) - Required - Feet as an integer. ### Returns - **float** - Miles as a float. ``` -------------------------------- ### Regions.get_routes Source: https://pyforks.mn-mtb.com/PyForks.html Retrieves a list of public routes with optional filtering and pagination. ```APIDOC ## get_routes(**kwargs) ### Description Return a list of public routes. ### Parameters - **scope** (str) - Optional - Detail level of route object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of routes to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Response - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### get_events(**kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/events.html Retrieves a list of events based on optional filtering and pagination parameters. ```APIDOC ## get_events(**kwargs) ### Description Returns a list of events. Supports filtering, sorting, and pagination. ### Parameters - **scope** (str) - Optional - Detail level of event object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of events to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### report(trailid, status, **kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Submits a new trail report to the API. ```APIDOC ## POST /report ### Description Submits a report for a specific trail with a given status and optional details. ### Parameters - **trailid** (int) - Required - ID of the trail. - **status** (int) - Required - Status of the trail. - **condition** (int) - Optional - Condition of the trail. - **description** (str) - Optional - Description of trail condition or issues. - **marker** (str) - Optional - Location of the report (lat, lon). ``` -------------------------------- ### Retrieve a specific event by ID Source: https://pyforks.mn-mtb.com/_modules/PyForks/events.html Fetches details for a single event using its unique identifier. Supports optional scope and field filtering via keyword arguments. ```python from PyForks.trailforks import Trailforks from typing import Any, Dict [docs]class Events(Trailforks): [docs] def get_event(self, id: int, **kwargs) -> Dict[str, Any]: """ Return a specific event. Args: id (int): ID of the event. **kwargs: Optional parameters such as: scope (str): Detail of the event object to return. fields (str): Limit the fields returned. Returns: Dict[str, Any]: Response data from the API. """ params = {'id': id} params.update(kwargs) response = self._get(f"{self.base_uri}/event", params=params) return response.json() ``` -------------------------------- ### Retrieve a specific route by ID Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Fetches details for a single route using its unique identifier. Supports optional scope and field filtering via kwargs. ```python def get_route(self, id: int, **kwargs) -> Dict[str, Any]: """ Return a specific route. Args: id (int): ID of the route. **kwargs: Optional parameters such as: scope (str): Detail of route object to return. fields (str): Limit the fields returned. Returns: Dict[str, Any]: Response data from the API. """ params = {'id': id} params.update(kwargs) response = self._get(f"{self.base_uri}/route", params=params) return response.json() ``` -------------------------------- ### Define Custom PyForks Exceptions Source: https://pyforks.mn-mtb.com/_modules/PyForks/exceptions.html Custom exception classes inheriting from the base Exception class to handle specific API error states. ```python class InvalidRegion(Exception): def __init__(self, msg="Not a valid Trailforks Region", *args, **kwargs): """ Invalid Trailforks Region Exception Handler Args: msg (str, optional): Message that's presented to the user. Defaults to 'Not a valid Trailforks Region'. """ # noqa super().__init__(msg, *args, **kwargs) class InvalidPermissions(Exception): def __init__(self, msg="Invalid Permissions", *args, **kwargs): """ User does not have necessary permissions exception handler Args: msg (str, optional): Message that's presented to the user. Defaults to 'Invalid Permissions'. """ # noqa super().__init__(msg, *args, **kwargs) class RegionLockedAPI(Exception): def __init__(self, msg="Invalid Permissions", *args, **kwargs): """ User has a regional locked API token for their app_id/app_secret Args: msg (str, optional): _description_. Defaults to "Invalid Permissions". """ super().__init__(msg, *args, **kwargs) class TrailforksAPIException(Exception): def __init__(self, msg="Invalid Permissions", *args, **kwargs): """ Generic Trailforks ARest API exception Handler Args: msg (str, optional): _description_. Defaults to "Invalid Permissions". """ super().__init__(msg, *args, **kwargs) ``` -------------------------------- ### get_trails Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Retrieves a list of trails based on provided filters and pagination. ```APIDOC ## GET /trails ### Description Return a list of trails. ### Method GET ### Endpoint /trails ### Parameters #### Query Parameters - **scope** (str) - Optional - Detail level of trail object to return. - **fields** (str) - Optional - Limit the fields returned by a comma-separated list of allowed fields. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of trails to return, max 500. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### PyForks.utilities.meters_to_miles Source: https://pyforks.mn-mtb.com/PyForks.html Converts a distance in meters to miles. ```APIDOC ## meters_to_miles(meters: float) -> float ### Description Translates meters to miles, useful for processing Trailforks API metric data. ### Parameters - **meters** (int) - Required - Total meters. ### Returns - **float** - Total miles. ``` -------------------------------- ### get_event(id: int, **kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/events.html Retrieves details for a specific event by its ID. ```APIDOC ## get_event(id: int, **kwargs) ### Description Returns a specific event object based on the provided ID. ### Parameters - **id** (int) - Required - ID of the event. - **scope** (str) - Optional - Detail of the event object to return. - **fields** (str) - Optional - Limit the fields returned. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### get_reports(**kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Retrieves a list of trail reports based on optional filters. ```APIDOC ## GET /reports ### Description Returns a list of reports with optional filtering, sorting, and pagination. ### Parameters - **scope** (str) - Optional - Detail level of report object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of reports to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ``` -------------------------------- ### get_trail Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Retrieves details for a specific trail by its ID. ```APIDOC ## GET /trail ### Description Return a specific trail. ### Method GET ### Endpoint /trail ### Parameters #### Query Parameters - **id** (int) - Required - ID of the trail. - **scope** (str) - Optional - Detail of trail object to return. - **fields** (str) - Optional - Limit the fields returned. ``` -------------------------------- ### get_ridelogs(**kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of ride logs for a trail or region. ```APIDOC ## get_ridelogs(**kwargs) ### Description Returns a list of ride logs for a trail or region, supporting filtering, sorting, and pagination. ### Parameters - **scope** (str) - Optional - Detail level of ride log object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of ride logs to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### get_poi(id: int, **kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a specific Point of Interest (POI) by its ID. ```APIDOC ## get_poi(id: int, **kwargs) ### Description Returns a specific Point of Interest (POI) based on the provided ID. ### Parameters - **id** (int) - Required - ID of the POI. - **scope** (str) - Optional - Detail of POI object to return. - **fields** (str) - Optional - Limit the fields returned. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### Retrieve Trailforks region data Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Methods for fetching POIs, regions, status, and ride logs from the Trailforks API. ```python from PyForks.trailforks import Trailforks from typing import Any, Dict [docs]class Regions(Trailforks): [docs] def get_poi(self, id: int, **kwargs) -> Dict[str, Any]: """ Return a specific Point of Interest (POI). Args: id (int): ID of the POI. **kwargs: Optional parameters such as: scope (str): Detail of POI object to return. fields (str): Limit the fields returned. Returns: Dict[str, Any]: Response data from the API. """ params = {'id': id} params.update(kwargs) response = self._get(f"{self.base_uri}/poi", params=params) return response.json() [docs] def get_region(self, id: int, **kwargs) -> Dict[str, Any]: """ Return a specific region. Args: id (int): ID of the region. **kwargs: Optional parameters such as: scope (str): Detail of region object to return. fields (str): Limit the fields returned. Returns: Dict[str, Any]: Response data from the API. """ params = {'id': id} params.update(kwargs) response = self._get(f"{self.base_uri}/region", params=params) return response.json() [docs] def get_region_status(self, since: int, **kwargs) -> Dict[str, Any]: """ Return region status & condition. Args: since (int): Timestamp to return status after. **kwargs: Optional parameters such as: rids (str): Comma-separated list of region IDs. trailids (str): Comma-separated list of trail IDs. reportdetail (int): Show details of the most recent trail report. Returns: Dict[str, Any]: Response data from the API. """ params = {'since': since} params.update(kwargs) response = self._get(f"{self.base_uri}/region_status", params=params) return response.json() [docs] def get_regions(self, **kwargs) -> Dict[str, Any]: """ Return a list of regions. Args: **kwargs: Optional parameters such as: scope (str): Detail level of region object to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of regions to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/regions", params=kwargs) return response.json() [docs] def get_ridelogs(self, **kwargs) -> Dict[str, Any]: """ Return a list of ride logs for trail or region. Args: **kwargs: Optional parameters such as: scope (str): Detail level of ride log object to return. fields (str): Limit the fields returned. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of ride logs to return. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/ridelogs", params=kwargs) return response.json() ``` -------------------------------- ### Regions.get_photos Source: https://pyforks.mn-mtb.com/PyForks.html Retrieves a list of trail or region photos based on optional filtering and pagination parameters. ```APIDOC ## get_photos(**kwargs) ### Description Returns a list of trail or region photos. ### Parameters - **scope** (str) - Optional - Detail level of photo objects to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of photos to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Response - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### get_regions(**kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves a list of regions based on optional filters and pagination. ```APIDOC ## get_regions(**kwargs) ### Description Returns a list of regions, supporting filtering, sorting, and pagination. ### Parameters - **scope** (str) - Optional - Detail level of region object to return. - **fields** (str) - Optional - Limit the fields returned. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. - **rows** (int) - Optional - Number of regions to return. - **page** (int) - Optional - Page through results. - **sort** (str) - Optional - Sort the results. - **order** (str) - Optional - Order the results. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### Retrieve map trails, specific trail, status, and list of trails Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Methods for fetching trail data from the Trailforks API. These methods return JSON response data. ```python from PyForks.trailforks import Trailforks from typing import Any, Dict [docs]class Trails(Trailforks): [docs] def get_map_trails(self, **kwargs) -> Dict[str, Any]: """ Return a list of trails within a bounding box for displaying on a map. Args: **kwargs: Optional parameters such as: output (str): Output format of the trails, default is Google encoded path. filter (str): Filter variables in the format 'field::value;field2::value2'. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/maptrails", params=kwargs) return response.json() [docs] def get_trail(self, id: int, **kwargs) -> Dict[str, Any]: """ Return a specific trail. Args: id (int): ID of the trail. **kwargs: Optional parameters such as: scope (str): Detail of trail object to return. fields (str): Limit the fields returned. Returns: Dict[str, Any]: Response data from the API. """ params = {'id': id} params.update(kwargs) response = self._get(f"{self.base_uri}/trail", params=params) return response.json() [docs] def get_trail_status(self, since: int, **kwargs) -> Dict[str, Any]: """ Return trail status & condition for trails in region. Args: since (int): Timestamp to return status after. **kwargs: Optional parameters such as: rids (str): Comma-separated list of region IDs. trailids (str): Comma-separated list of trail IDs. reportdetail (int): Show details of the most recent trail report. Returns: Dict[str, Any]: Response data from the API. """ params = {'since': since} params.update(kwargs) response = self._get(f"{self.base_uri}/trail_status", params=params) return response.json() [docs] def get_trails(self, **kwargs) -> Dict[str, Any]: """ Return a list of trails. Args: **kwargs: Optional parameters such as: scope (str): Detail level of trail object to return. fields (str): Limit the fields returned by a comma-separated list of allowed fields. filter (str): Filter variables in the format 'field::value;field2::value2'. rows (int): Number of trails to return, max 500. page (int): Page through results. sort (str): Sort the results. order (str): Order the results. Returns: Dict[str, Any]: Response data from the API. """ response = self._get(f"{self.base_uri}/trails", params=kwargs) return response.json() ``` -------------------------------- ### get_region_status(since: int, **kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves the status and condition of regions since a specific timestamp. ```APIDOC ## get_region_status(since: int, **kwargs) ### Description Returns region status and condition information for data updated after the specified timestamp. ### Parameters - **since** (int) - Required - Timestamp to return status after. - **rids** (str) - Optional - Comma-separated list of region IDs. - **trailids** (str) - Optional - Comma-separated list of trail IDs. - **reportdetail** (int) - Optional - Show details of the most recent trail report. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### Convert meters to miles Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Converts metric measurements from the Trailforks API into miles. ```python def meters_to_miles(meters: float) -> float: """ Translates meters to miles since the trailforks uses metric measurements for their API. Args: meters (int): Total Meters Returns: float: Total Miles """ meters = float(meters) miles = meters * 0.00062137 return miles ``` -------------------------------- ### has_numbers(data: str) -> bool Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Checks if a string contains any numeric characters. ```APIDOC ## has_numbers(data: str) -> bool ### Description Determines if there are numbers present in the provided string. ### Parameters - **data** (str) - Required - The string to check. ### Returns - **bool** - True if numbers exist, False otherwise. ``` -------------------------------- ### meters_to_miles(meters: float) -> float Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Converts a value in meters to miles, useful for processing Trailforks API metric data. ```APIDOC ## meters_to_miles(meters: float) -> float ### Description Translates meters to miles. ### Parameters - **meters** (float) - Required - The distance in meters. ### Returns - **float** - The calculated distance in miles. ``` -------------------------------- ### get_map_trails Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Retrieves a list of trails within a bounding box for display on a map. ```APIDOC ## GET /maptrails ### Description Return a list of trails within a bounding box for displaying on a map. ### Method GET ### Endpoint /maptrails ### Parameters #### Query Parameters - **output** (str) - Optional - Output format of the trails, default is Google encoded path. - **filter** (str) - Optional - Filter variables in the format 'field::value;field2::value2'. ``` -------------------------------- ### feet_to_miles(feet: int) -> float Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Converts an integer value representing feet into miles. ```APIDOC ## feet_to_miles(feet: int) -> float ### Description Translates a value in feet into miles. ### Parameters - **feet** (int) - Required - The distance in feet. ### Returns - **float** - The calculated distance in miles. ``` -------------------------------- ### Convert feet to miles Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Translates an integer or string representation of feet into miles as a float. ```python def feet_to_miles(feet: int) -> float: """ Translate feet into miles Args: feet (int): feet as a integer Returns: float: miles as a float """ if isinstance(feet, str): feet = int(feet.replace(",", "").strip()) mi = 0.000189394 return feet * mi ``` -------------------------------- ### distance_string_to_miles_float(distance: str) -> float Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Normalizes a distance string (e.g., '1456 ft', '2.3mi') into a float representing miles. ```APIDOC ## distance_string_to_miles_float(distance: str) -> float ### Description Attempts to normalize mixed distance values from report data into miles as a float. ### Parameters - **distance** (str) - Required - The distance string to convert (e.g., '1456 ft', '2.3mi'). ### Returns - **float** - The calculated distance in miles. ``` -------------------------------- ### get_region(id: int, **kwargs) Source: https://pyforks.mn-mtb.com/_modules/PyForks/regions.html Retrieves details for a specific region by its ID. ```APIDOC ## get_region(id: int, **kwargs) ### Description Returns a specific region based on the provided ID. ### Parameters - **id** (int) - Required - ID of the region. - **scope** (str) - Optional - Detail of region object to return. - **fields** (str) - Optional - Limit the fields returned. ### Returns - **Dict[str, Any]** - Response data from the API. ``` -------------------------------- ### PyForks.utilities.distance_string_to_miles_float Source: https://pyforks.mn-mtb.com/PyForks.html Normalizes mixed distance string formats from Trailforks report data into a float representing miles. ```APIDOC ## distance_string_to_miles_float(distance: str) -> float ### Description Attempts to normalize mixed distance values (e.g., '1456 ft', '2.3mi') into miles as a float. ### Parameters - **distance** (str) - Required - String of distance to convert. ### Returns - **float** - The distance in miles. ``` -------------------------------- ### Convert distance string to miles float Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Normalizes mixed distance strings like '1456 ft' or '2.3mi' into a float representing miles. ```python def distance_string_to_miles_float(distance: str) -> float: """ Trailforks report data has mixed distance values, this function attempts to normalize them into miles (float) Args: distance (str): string of distance, 1456 ft, 2.3mi Returns: float: number of miles """ feet_strings = ["ft", "feet"] distance = distance.replace('"', "") try: if any(x in distance for x in feet_strings): distance_int = int(distance.split(" ")[0].replace(",", "")) mi = 0.000189394 return distance_int * mi else: return float(distance.split(" ")[0]) except Exception as e: logging.error(f"distance casting failed;ERROR:{e}") return 0 ``` -------------------------------- ### get_trail_status Source: https://pyforks.mn-mtb.com/_modules/PyForks/trails.html Retrieves the status and condition of trails within a region since a specific timestamp. ```APIDOC ## GET /trail_status ### Description Return trail status & condition for trails in region. ### Method GET ### Endpoint /trail_status ### Parameters #### Query Parameters - **since** (int) - Required - Timestamp to return status after. - **rids** (str) - Optional - Comma-separated list of region IDs. - **trailids** (str) - Optional - Comma-separated list of trail IDs. - **reportdetail** (int) - Optional - Show details of the most recent trail report. ``` -------------------------------- ### Check for numbers in string Source: https://pyforks.mn-mtb.com/_modules/PyForks/utilities.html Determines if a string contains any numeric characters. ```python def has_numbers(data: str) -> bool: """ Determines if there are numbers in a string Args: data (str): String to check Returns: bool: True: numbers exist; False: numbers do not exist """ try: check = any(char.isdigit() for char in data) return check except TypeError: return True ``` -------------------------------- ### PyForks.utilities.has_numbers Source: https://pyforks.mn-mtb.com/PyForks.html Checks if a string contains any numeric characters. ```APIDOC ## has_numbers(data: str) -> bool ### Description Determines if there are numbers in a provided string. ### Parameters - **data** (str) - Required - String to check. ### Returns - **bool** - True if numbers exist, False otherwise. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.