the terminal api gives you access to the same api that powers the award winning terminal ssh shop.
The Terminal API allows you to interact with the Terminal e-commerce platform. You can use it to order your own coffee however you like (cron job, neovim plugin, github action, etc.), or even create apps that allow others to authenticate through OAuth 2.0 and purchase their coffee.
There are two environments for the Terminal API: the dev sandbox, and production. The dev sandbox allows you to test out the API without creating real charges against a credit card (use the Stripe test card: 4242424242424242), and, obviously, we won't be fulfilling any orders in dev. The production environment is the real deal, and we will be fulfilling orders against real credit cards, so be careful! Or don't, we'll gladly take your money and send you coffee, just no infinite loops, pls.
We don't know what you might do with it, but our OpenAPI 3.1 specification is available here.
There are two ways to authenticate with the Terminal API: using a personal access token, or using an OAuth 2.0 client ID and secret.
The personal access token is a simple secret (string) that can be passed as a bearer token in the Authorization
header. All API actions will be performed on behalf of the user associated with the token (you!). You can manage your personal access tokens in the Account page of the SSH shop:
ssh dev.terminal.shop -t tokens # dev sandbox
ssh terminal.shop -t tokens # production
The OAuth 2.0 client ID and secret are used to authenticate with the API on behalf of another user. Like personal access tokens, you can create and manage OAuth 2.0 apps in the Account page of the SSH shop:
ssh dev.terminal.shop -t apps # dev sandbox
ssh terminal.shop -t apps # production
You can find OAuth 2.0 configuration info here for the dev sandbox, and here for production. Note: we don't do anything with `scope`, so pass anything you like just remember that we probably log them and will post any funny values on the internet.
If you don't prefer making HTTP requests yourself, you can use one of our many client SDKs to interact with the Terminal API.
note: Our SDKs are created by the talented team at Stainless, they're awesome and you should check them out.
list products
public
get product
public
public
List all products for sale in the Terminal shop.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const products = await client.product.list();
console.log(products.data);
}
main();
public
Get a product by ID from the Terminal shop.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const product = await client.product.get('prd_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(product.data);
}
main();
get profile
update profile
Get the current user's profile.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.profile.me();
console.log(response.data);
}
main();
Update the current user's profile.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const profile = await client.profile.update({ email: 'john@example.com', name: 'John Doe' });
console.log(profile.data);
}
main();
get addresses
get address
create address
delete address
Get the shipping addresses associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const addresses = await client.address.list();
console.log(addresses.data);
}
main();
Get the shipping address with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const address = await client.address.get('shp_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(address.data);
}
main();
Create and add a shipping address to the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const address = await client.address.create({
city: 'Anytown',
country: 'US',
name: 'John Doe',
street1: '123 Main St',
zip: '12345',
});
console.log(address.data);
}
main();
Delete a shipping address from the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const address = await client.address.delete('shp_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(address.data);
}
main();
list cards
get card
create card
collect card
delete card
List the credit cards associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const cards = await client.card.list();
console.log(cards.data);
}
main();
Get a credit card by ID associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const card = await client.card.get('crd_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(card.data);
}
main();
Attach a credit card (tokenized via Stripe) to the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const card = await client.card.create({ token: 'tok_1N3T00LkdIwHu7ixt44h1F8k' });
console.log(card.data);
}
main();
Create a temporary URL for collecting credit card information for the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.card.collect();
console.log(response.data);
}
main();
Delete a credit card associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const card = await client.card.delete('crd_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(card.data);
}
main();
get cart
add item
set address
set card
convert to order
clear cart
Get the current user's cart.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const cart = await client.cart.get();
console.log(cart.data);
}
main();
Add an item to the current user's cart.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.cart.setItem({
productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX',
quantity: 2,
});
console.log(response.data);
}
main();
Set the shipping address for the current user's cart.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.cart.setAddress({ addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX' });
console.log(response.data);
}
main();
Set the credit card for the current user's cart.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.cart.setCard({ cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX' });
console.log(response.data);
}
main();
Convert the current user's cart to an order.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.cart.convert();
console.log(response.data);
}
main();
Clear the current user's cart.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.cart.clear();
console.log(response.data);
}
main();
list orders
get order
create order
List the orders associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const orders = await client.order.list();
console.log(orders.data);
}
main();
Get the order with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const order = await client.order.get('ord_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(order.data);
}
main();
Create an order without a cart. The order will be placed immediately.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const order = await client.order.create({
addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX',
cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX',
variants: { var_XXXXXXXXXXXXXXXXXXXXXXXXX: 1 },
});
console.log(order.data);
}
main();
list subscriptions
get subscription
update subscription
subscribe
cancel
List the subscriptions associated with the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const subscriptions = await client.subscription.list();
console.log(subscriptions.data);
}
main();
Get the subscription with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscription.get('sub_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(subscription.data);
}
main();
Update card, address, or interval for an existing subscription.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscription.update('sub_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(subscription.data);
}
main();
Create a subscription for the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscription.create({
id: 'sub_XXXXXXXXXXXXXXXXXXXXXXXXX',
addressID: 'shp_XXXXXXXXXXXXXXXXXXXXXXXXX',
cardID: 'crd_XXXXXXXXXXXXXXXXXXXXXXXXX',
created: '2024-06-29T19:36:19.000Z',
price: 2200,
productVariantID: 'var_XXXXXXXXXXXXXXXXXXXXXXXXX',
quantity: 1,
});
console.log(subscription.data);
}
main();
Cancel a subscription for the current user.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscription.delete('sub_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(subscription.data);
}
main();
list tokens
get token
create token
delete token
List the current user's personal access tokens.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const tokens = await client.token.list();
console.log(tokens.data);
}
main();
Get the personal access token with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const token = await client.token.get('pat_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(token.data);
}
main();
Create a personal access token.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const token = await client.token.create();
console.log(token.data);
}
main();
Delete the personal access token with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const token = await client.token.delete('pat_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(token.data);
}
main();
list apps
get app
create app
delete app
List the current user's registered apps.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const apps = await client.app.list();
console.log(apps.data);
}
main();
Get the app with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const app = await client.app.get('cli_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(app.data);
}
main();
Create an app.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const app = await client.app.create({ name: 'Example App', redirectURI: 'https://example.com/callback' });
console.log(app.data);
}
main();
Delete the app with the given ID.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const app = await client.app.delete('cli_XXXXXXXXXXXXXXXXXXXXXXXXX');
console.log(app.data);
}
main();
get app data
subscribe email
public
Get initial app data, including user, products, cart, addresses, cards, subscriptions, and orders.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const response = await client.view.init();
console.log(response.data);
}
main();
public
Subscribe to email updates from Terminal.
import Terminal from '@terminaldotshop/sdk';
const client = new Terminal({
bearerToken: process.env['TERMINAL_BEARER_TOKEN'], // This is the default and can be omitted
});
async function main() {
const email = await client.email.create({ email: 'john@example.com' });
console.log(email.data);
}
main();