sofarocean / sofar-api-client-python

Python Client for Wavefleet
Apache License 2.0
7 stars 5 forks source link

F/search #30

Closed pieterbartsmit closed 2 years ago

pieterbartsmit commented 2 years ago

This adds the search endpointto pysofar. Sample use:

from pysofar.sofar import SofarApi
sofarapi = SofarApi()

# Define parameters (as documented)
shape_params = [(40,-60),(30,-50)]
shape = 'envelope'
start_date = '2022-06-01T00:00:00Z'
end_date = '2022-06-02T00:00:00Z'
page_size=100

# get the data
data = sofarapi.search(shape,shape_params,start_date,end_date,page_size=page_size)

Note that pagination is abstracted away from the user using a simple generator function. If desired, the generator can be retrieved explicitly, allowing for just in time downloading of data:

data = sofarapi.search(shape,shape_params,start_date,end_date,page_size=page_size,return_generator=True)

for spotter in data:
      ( do something with the spotter data)

Returned data is just the raw json response translated to Python types.