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
Installation
The Python SDK is available as a PyPI package,
airplanesdk
. To install it, run:bashCopied1$ pip install airplanesdk
The source code is available on GitHub.
The PyPI package
airplane
(without the sdk
suffix) is unrelated to Airplane.Basic usage
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.
typescriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "lookup_users",6parameters: {7name: "shorttext",8},9resources: ["demo_db"],10},11async (params) => {12console.log(`Looking up users like '${params.name}'`);13const run = await airplane.sql.query<{14id: string;15name: string;16email: string;17}>(18"demo_db",19`20select id, name, email from users21where (name ilike :name or email ilike :name)22order by name asc23`,24{ args: { name: `%${params.name}%` } },25);2627const users = run.output.Q1;28await airplane.display.table(users);2930return {31numUsers: users.length,32};33},34);
pythonCopied1import airplane23@airplane.task(4resources=[airplane.Resource("demo_db")],5)6def lookup_users(name: str):7print(f"Looking up users like '{name}'")8run = airplane.sql.query(9"demo_db",10"""11select id, name, email from users12where (name ilike :name or email ilike :name)13order by name asc14""",15query_args={"name": "%" + name + "%"}16)17users = run.output["Q1"]18airplane.display.table(users)19return {20"num_users": len(users),21}

Next
Next
For details and examples, see the various pages below.