SDKs

SDKs provide utilities to interact with the Airplane platform.
Airplane has official SDKs in JavaScript and Python that provide utilities for interacting with the Airplane platform from tasks and views.
Each SDK is built on top of the Airplane API. If using a different language (e.g., via a Shell or Docker task), then you can use the API to perform the same operations without an official SDK.

Installation

The JavaScript SDK is available as an NPM package airplane. To install it, run:
bash
Copied
1
$ npm install airplane
The source code is available on GitHub.

Basic usage

Here's a simple example of how the SDK can be used to configure a task as code. The example selects users from a database, displays the users in a table, and returns (as output) the number of users that matched.
typescript
Copied
1
import airplane from "airplane";
2
3
export default airplane.task(
4
{
5
slug: "lookup_users",
6
parameters: {
7
name: "shorttext",
8
},
9
resources: ["demo_db"],
10
},
11
async (params) => {
12
console.log(`Looking up users like '${params.name}'`);
13
const run = await airplane.sql.query<{
14
id: string;
15
name: string;
16
email: string;
17
}>(
18
"demo_db",
19
`
20
select id, name, email from users
21
where (name ilike :name or email ilike :name)
22
order by name asc
23
`,
24
{ args: { name: `%${params.name}%` } },
25
);
26
27
const users = run.output.Q1;
28
await airplane.display.table(users);
29
30
return {
31
numUsers: users.length,
32
};
33
},
34
);

Next

For details and examples, see the various pages below.