kbws.main module#

## FDSN Web Services for KB Core databases.

Use common FDSN-WS data access clients to work with local databases.

Read about the [FDSN Web Services specificaton.](https://www.fdsn.org/webservices).

Get files using: [ObsPy’s Mass Downloader](https://docs.obspy.org/packages/autogen/obspy.clients.fdsn.mass_downloader.html#module-obspy.clients.fdsn.mass_downloader), [Rover](https://earthscope.github.io/rover/), [SOD](http://www.seis.sc.edu/sod/), curl or wget, or your web browser!

Get live data using: [ObsPy’s FDSN Client](https://docs.obspy.org/packages/obspy.clients.fdsn.html#module-obspy.clients.fdsn), [irisFetch.m for MATLAB](iris-edu/irisFetch-matlab)

Note: Not all tools will work out-of-the-box while supporting services are implemented.

### Example: ObsPy FDSN Client

If Python does not trust a deployment certificate trusted by the operating system (common on macOS), inject the system trust store before importing ObsPy:

`python import truststore truststore.inject_into_ssl() `

`python from obspy import UTCDateTime from obspy.clients.fdsn import Client client = Client(<IP address>, _discover_services=False) client.get_waveforms(network='TA', station='A25A', location='--', channel='BH?', starttime=UTCDateTime('2010-03-25T00:00:00'), endtime=UTCDateTime('2010-03-28T00:00:00')) `

…results in

`python 3 Trace(s) in Stream: .A25A..BHE | 2010-03-27T23:50:07.000000Z - 2010-03-28T00:00:00.000000Z | 40.0 Hz, 23721 samples .A25A..BHN | 2010-03-27T23:50:07.000000Z - 2010-03-28T00:00:00.000000Z | 40.0 Hz, 23721 samples .A25A..BHZ | 2010-03-27T23:50:07.000000Z - 2010-03-28T00:00:00.000000Z | 40.0 Hz, 23721 samples `

The _discover_services keyword allows you to bypass the need for a properly-formatted [WADL](https://en.wikipedia.org/wiki/Web_Application_Description_Language) file for the service, because it’s silly that not having this file should cause a request to fail. I’m just sayin’.

async kbws.main.add_request_metadata(request: Request, call_next)[source]#
kbws.main.get_description() → str[source]#

Return the default Markdown description or a deployment override.

async kbws.main.internal_error_handler(request: Request, exc)[source]#
kbws.main.read_openapi_yaml()[source]#
async kbws.main.unavailable_service_handler(request: Request, exc: ServiceUnavailable)[source]#
kbws.main.use_route_names_as_operation_ids(app: FastAPI) → None[source]#

Simplify operation IDs so that generated API clients have simpler function names.

Note: Should be called only after all routes have been added.

async kbws.main.validation_exception_handler(request: Request, exc)[source]#