Client reference
A Client provides a connection to a Beacon Node, manages authentication headers and exposes helpers for
discovering tables/datasets before building JSON or SQL queries.
Source code in beacon_api/client.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
__init__(url, proxy_headers=None, jwt_token=None, basic_auth=None)
Create a Beacon API client.
Args:
url: Base Beacon Node URL, e.g. "https://beacon-node.example.com".
proxy_headers: Optional custom headers added to every request.
jwt_token: Optional bearer token used for Authorization header.
basic_auth: Optional (username, password) tuple for HTTP basic auth.
Raises:
ValueError: If basic_auth is not a 2-item tuple.
Exception: When the Beacon Node health endpoint cannot be reached.
Source code in beacon_api/client.py
available_columns()
Return column names for the default table (deprecated).
Source code in beacon_api/client.py
check_status()
Verify that the Beacon Node responds to /api/health.
Returns: None. The method prints diagnostic information on success.
Raises: Exception: If the Beacon Node returns a non-200 response.
Source code in beacon_api/client.py
create_logical_table(table_name, dataset_glob_paths, file_format, description=None, force=False, **kwargs)
Create a new logical table on the Beacon Node.
Args: table_name: Name of the new logical table. dataset_glob_paths: List of dataset file paths (can include glob patterns). file_format: Format of the dataset files (e.g. "parquet", "csv", "zarr"). description: Optional description of the logical table. **kwargs: Additional parameters specific to the file format. (e.g. delimiter for CSV, Zarr statistics columns)
Raises: Exception: If the creation fails.
Source code in beacon_api/client.py
delete_dataset(dataset_path, force=False)
Delete a dataset file from the Beacon Node.
Args: dataset_path: Path to the dataset file on the Beacon Node.
Raises: Exception: If the deletion fails.
Source code in beacon_api/client.py
delete_table(table_name, force=False)
Delete a logical table from the Beacon Node.
Args: table_name: Name of the logical table to delete. Raises: Exception: If the deletion fails.
Source code in beacon_api/client.py
download_dataset(dataset_path, local_path, force=False)
Download a dataset file from the Beacon Node to a local path.
Args: dataset_path: Path to the dataset file on the Beacon Node. local_path: Local path where the file will be saved. Raises: Exception: If the download fails.
Source code in beacon_api/client.py
get_server_info()
Return the server metadata exposed by /api/info.
Source code in beacon_api/client.py
list_datasets(pattern=None, limit=None, offset=None, force=False)
Enumerate datasets registered with the Beacon node.
Args: pattern: Optional glob-like filter applied by the server. limit: Optional page size to cap the number of results. offset: Optional offset for pagination.
Returns:
dict[str, Dataset]: Mapping from file path to :class:Dataset helper.
Raises: Exception: If the Beacon Node version < 1.4.0 or the HTTP call fails.
Source code in beacon_api/client.py
list_tables()
Retrieve all logical tables available on the Beacon Node.
Returns:
dict[str, DataTable]: Mapping of table name to :class:DataTable helper.
Source code in beacon_api/client.py
query()
Create a new query object. This is the starting point for building a query. The query can then be built using the methods on the Query object. You can also create a query from a specific table from the list_tables() method.
To materialize and run the query, use the .to_dataframe() or .to_csv() methods on the Query object. Returns: JSONQuery: A new query object.
Source code in beacon_api/client.py
sql_query(sql)
Create a new :class:SQLQuery for direct SQL execution.
Args: sql: Raw SQL string sent to the Beacon Node.
Returns:
SQLQuery: Builder that exposes to_dataframe, to_csv etc.
Source code in beacon_api/client.py
subset(longitude_column, latitude_column, time_column, depth_column, columns, bbox=None, depth_range=None, time_range=None)
Create a query to subset the default collection based on the provided parameters.
Args: longitude_column: Name of the column containing longitude values. latitude_column: Name of the column containing latitude values. time_column: Name of the column containing time values. depth_column: Name of the column containing depth values. columns: List of additional columns to include in the query. bbox: Optional bounding box defined as (min_longitude, min_latitude, max_longitude, max_latitude). depth_range: Optional range for depth defined as (min_depth, max_depth). time_range: Optional range for time defined as (start_time, end_time). Returns JSONQuery: Query object that can be executed to retrieve the subset.
Source code in beacon_api/client.py
upload_dataset(file_path, destination_path, force=False)
Upload a local dataset file to the Beacon Node.
Args: file_path: Path to the local file to upload. destination_path: Destination path on the Beacon Node.
Raises: Exception: If the upload fails.