sdwis_drink_water.api
Module Contents
Classes
The SdwisAPI class provides an interface to interact with the EPA's SDWIS data service. |
Attributes
- sdwis_drink_water.api.log
- class sdwis_drink_water.api.SdwisAPI(base_url='https://data.epa.gov/efservice', retry_count=0, retry_delay=0, timeout=10, user_agent=None, enable_cache=True, cache_time=3600, print_url=False)
The SdwisAPI class provides an interface to interact with the EPA’s SDWIS data service. It supports making HTTP requests with optional caching and retries.
- base_url
The base URL for the EPA’s data service.
- Type:
str
- retry_count
Number of times to retry a request on failure.
- Type:
int
- retry_delay
Delay between retries in seconds.
- Type:
int
- timeout
Timeout for the HTTP requests.
- Type:
int
- enable_cache
Flag to enable or disable request caching.
- Type:
bool
- cache_time
Duration for which the cache is valid.
- Type:
int
- print_url
Flag to enable or disable printing of the request URL.
- Type:
bool
- user_agent
User agent string for the HTTP requests.
- Type:
str
- get_request(url, endpoint_parameters=(), params=None, only_count=False, headers=None, use_cache=True, multi_mode=False, **kwargs)
Sends a GET request to the specified URL with optional parameters.
- Parameters:
url (str) – The URL to send the request to.
endpoint_parameters (tuple) – Additional parameters for the endpoint.
params (dict) – Query parameters for the request.
only_count (bool) – Flag to return only count in the response.
headers (dict) – HTTP headers for the request.
use_cache (bool) – Flag to use cache for the request.
multi_mode (bool) – Flag to enable or disable multi-threading mode.
kwargs – Additional keyword arguments.
- Returns:
Parsed JSON response from the API / Or number
- Return type:
dict or int
- Raises:
SdwisHTTPException – If the HTTP request fails or returns an error.