Internals#

Lower-level building blocks. Most users never need these directly.

HTTP client#

class BaseClient(config=None, transport=None)[source]#

Sends GET requests to SGU through a transport and pages through results.

Parameters:
  • config (SGUConfig | None) – Configuration object. If None, uses default config.

  • transport (Transport | None) – Where requests go. If None, a RequestsTransport is built from the config and closed by close(). A transport you pass in is yours to close.

get(endpoint, params=None, base_url=None)[source]#

GET an endpoint, fetching every page of a FeatureCollection.

Parameters:
  • endpoint (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • base_url (str | None) – Optional override for base URL (for different API endpoints)

Return type:

dict[str, Any]

Returns:

JSON response data, with all features if the response was paginated

Raises:
close()[source]#

Close the transport, if this client created it.

Return type:

None

pandas helpers#

Pandas utilities with optional dependency handling.

exception PandasImportError(feature='this feature')[source]#

Raised when pandas functionality is used but pandas is not installed.

check_pandas_available(feature='this feature')[source]#

Check if pandas is available and raise helpful error if not.

Parameters:

feature (str) – Description of the feature that requires pandas

Raises:

PandasImportError – If pandas is not available

Return type:

None

get_pandas()[source]#

Get pandas module with proper error handling.

Return type:

Any

Returns:

The pandas module

Raises:

PandasImportError – If pandas is not available

optional_pandas_method(feature_name)[source]#

Decorator to mark methods that require pandas.