# Arrow Flight Client reference

`FlightClient` uses one gRPC channel. Create a path descriptor with `pathDescriptor()`. Create a command descriptor with `commandDescriptor()`.

## Client methods

| Method | Purpose | Return type |
| --- | --- | --- |
| `listFlights()` | Discover resources advertised by the server. | `AsyncIterable<FlightInfo>` |
| `getFlightInfo()` | Get the schema and endpoints for a descriptor. | `Promise<FlightInfo>` |
| `pollFlightInfo()` | Query the state of an ongoing request. | `Promise<FlightPollInfo>` |
| `getSchema()` | Get the Arrow schema for a descriptor. | `Promise<Schema>` |
| `doGet()` | Open a stream of batches using a ticket. | `Promise<FlightStreamReader>` |
| `getTable()` | Read the ticket's data into a complete table. | `Promise<Table>` |
| `doPut()` | Upload a table or a sequence of batches. | `AsyncIterable<FlightPutResult>` |
| `putTable()` | Upload a table and collect the server responses. | `Promise<readonly FlightPutResult[]>` |
| `doAction()` | Run a server action and stream its results. | `AsyncIterable<FlightActionResult>` |
| `listActions()` | List the actions supported by the server. | `AsyncIterable<FlightActionType>` |
| `close()` | Abort the client's active calls and close its channel. | `Promise<void>` |

## Streams and Arrow IPC

`FlightStreamReader` associates each `RecordBatch` with its application metadata. Metadata-only messages are read in order as the stream is consumed. Call `getTable()` to read the complete table.

The client converts batches between Flight framing and Arrow IPC. In `doPut()`, the first message contains the descriptor. When `FlightPutOptions.appMetadata` is non-empty, a metadata-only message follows the schema even for an empty sequence of batches.

`doPut()` accepts tables and batches from the ESM and CommonJS builds of a single `apache-arrow` installation. The client preserves the supplied schema and batch boundaries even when one stream contains batches from both builds.

`maxReceiveMessageLength` and `maxSendMessageLength` set gRPC limits in bytes for each serialized `FlightData` message. Allow room for message overhead when sizing a `RecordBatch`. The caller determines each batch size.

## Call options and cleanup

- Client `metadata` applies to every call. A matching value in `FlightCallOptions.metadata` replaces the client value. An empty array removes the key for one call.
- `signal` takes an `AbortSignal`. Cancelling the request raises `AbortError`. Pass an absolute `Date` as the `deadline`. An expired deadline yields a `ClientError` with code `DEADLINE_EXCEEDED`.
- `onTrailer` receives trailing metadata, including for a failed call. Values arrive as arrays of strings or copies of `Uint8Array`. [Error handling example](/arrow-flight-client/examples/error-details)
- `close()` can be called repeatedly. It aborts active calls with `AbortError`, including a `DoGet` opened before reading begins. Create a new client for later calls after closing the channel.

## Protocol access

`FlightClient.raw` exposes the low-level client on the same channel. The `flightProtocol` namespace includes messages, codecs, enums, `FlightServiceDefinition`, and the `FlightRawClient` type.

```ts
import { flightProtocol } from 'arrow-flight-client';

export type RawClient = flightProtocol.FlightRawClient;
```

`Handshake` and `DoExchange` are available through `FlightClient.raw`. For low-level `DoExchange`, the caller handles Arrow IPC framing. `FlightRawCallOptions` configures these calls.

The ProtoJSON codecs write `NaN`, `Infinity`, and `-Infinity` as strings. Decoding fails when a 64-bit integer is outside JavaScript’s safe integer range.

`DoGet` uses the current client's address. Use the server's endpoint address when choosing a different connection. [Flight contract](https://github.com/woodger/arrow-flight-client/blob/0.0.19/contracts/Flight.proto)

The release documentation describes the exported types and the migration from `arrow-flight-client/raw`. [Public API](https://github.com/woodger/arrow-flight-client/blob/0.0.19/docs/public-api.md)

The client code is licensed under MIT. The Flight protocol definition and its generated bindings are licensed under Apache 2.0. [License notice](https://github.com/woodger/arrow-flight-client/blob/0.0.19/NOTICE)
