# Arrow Flight Client

An Apache Arrow Flight client for Node.js. It provides typed access to every unary and streaming gRPC method in the official Flight protocol definition.

## Installation

Install the client and its required `apache-arrow` peer dependency in your project.

```sh
npm install arrow-flight-client apache-arrow
```

## Read a table

Start the [local Flight server](/arrow-flight-client/examples/local-server). It serves a table with the descriptor `demo/people`. Call `getFlightInfo()` to get information about the table, then pass the returned ticket to `getTable()`.

`client.ts`

```ts
import { FlightClient, pathDescriptor } from 'arrow-flight-client';

const client = new FlightClient('127.0.0.1:8815');

try {
  const info = await client.getFlightInfo(pathDescriptor('demo', 'people'));
  const ticket = info.endpoints[0]?.ticket;

  if (!ticket) {
    throw new Error('The Flight endpoint has no ticket');
  }

  const table = await client.getTable(ticket);
  console.log(table.toString());
}
finally {
  await client.close();
}
```

Run the example with the following command. The output contains two rows with the names `Ada` and `Lin`.

```sh
node client.ts
```
