#terminal api

v1.0.3

the terminal api gives you access to the same api that powers the award winning terminal ssh shop.

#servers

  • https://api.dev.terminal.shop (Dev Sandbox)
  • https://api.terminal.shop (Production)

#getting started

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.

#authentication

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.

#client sdks

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.

#Product

GET

/product

list products

public

GET

/product/{id}

get product

public

get

/product

public

List all products for sale in the Terminal shop.

#responses

get

/product/{id}

public

Get a product by ID from the Terminal shop.

#parameters

idstringID of the product to get.
example: `prd_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

#Profile

GET

/profile

get profile

PUT

/profile

update profile

get

/profile

Get the current user's profile.

#responses

put

/profile

Update the current user's profile.

#request

#responses

#Address

GET

/address

get addresses

GET

/address/{id}

get address

POST

/address

create address

DELETE

/address/{id}

delete address

PATCH

/address/{id}

update address

get

/address

Get the shipping addresses associated with the current user.

#responses

get

/address/{id}

Get the shipping address with the given ID.

#parameters

idstringID of the shipping address to get.
example: `shp_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

post

/address

Create and add a shipping address to the current user.

#request

#responses

delete

/address/{id}

Delete a shipping address from the current user.

#parameters

idstringID of the shipping address to delete.
example: `shp_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

patch

/address/{id}

Update a saved shipping address without changing its ID, so carts and subscriptions keep referencing the same saved address.

#parameters

idstringID of the shipping address to update.
example: `shp_XXXXXXXXXXXXXXXXXXXXXXXXX`

#request

#responses

#Card

GET

/card

list cards

GET

/card/{id}

get card

POST

/card

create card

POST

/card/collect

collect card

DELETE

/card/{id}

delete card

get

/card

List the credit cards associated with the current user.

#responses

get

/card/{id}

Get a credit card by ID associated with the current user.

#parameters

idstringID of the card to get.
example: `crd_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

post

/card

Attach a credit card (tokenized via Stripe) to the current user.

#request

#responses

post

/card/collect

Create a temporary URL for collecting credit card information for the current user.

#responses

delete

/card/{id}

Delete a credit card associated with the current user.

#parameters

idstringID of the card to delete.
example: `crd_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

#Cart

GET

/cart

get cart

PUT

/cart/item

add item

PUT

/cart/address

set address

PUT

/cart/card

set card

POST

/cart/convert

convert to order

DELETE

/cart

clear cart

get

/cart

Get the current user's cart.

#responses

put

/cart/item

Add an item to the current user's cart.

#request

#responses

put

/cart/address

Set the shipping address for the current user's cart.

#request

#responses

put

/cart/card

Set the credit card for the current user's cart.

#request

#responses

post

/cart/convert

Convert the current user's cart to an order.

#parameters

idempotency-keystringStable key for safely retrying this cart conversion.
example: ``

#responses

delete

/cart

Clear the current user's cart.

#responses

#Order

GET

/order

list orders

GET

/order/{id}

get order

POST

/order

create order

DELETE

/order/{id}

cancel order

PATCH

/order/{id}/shipping

update order shipping

get

/order

List the orders associated with the current user.

#responses

get

/order/{id}

Get the order with the given ID.

#parameters

idstringID of the order to get.
example: `ord_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

post

/order

Create an order without a cart. The order will be placed immediately.

#parameters

idempotency-keystringStable key for safely retrying this logical checkout. Existing clients may omit it, but retries are only idempotent when it is supplied.
example: ``

#request

#responses

delete

/order/{id}

Cancel an order before fulfillment has started. Canceled orders are removed from order history.

#parameters

idstringID of the order to cancel.
example: `ord_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

patch

/order/{id}/shipping

Update the shipping address for an order before fulfillment has started.

#parameters

idstringID of the order to update.
example: `ord_XXXXXXXXXXXXXXXXXXXXXXXXX`

#request

#responses

#Subscription

GET

/subscription

list subscriptions

GET

/subscription/{id}

get subscription

PUT

/subscription/{id}

update subscription

POST

/subscription

subscribe

DELETE

/subscription/{id}

cancel

get

/subscription

List the subscriptions associated with the current user.

#responses

get

/subscription/{id}

Get the subscription with the given ID.

#parameters

idstringID of the subscription to get.
example: `sub_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

put

/subscription/{id}

Update card, address, or interval for an existing subscription.

#parameters

idstringID of the subscription to update.
example: `sub_XXXXXXXXXXXXXXXXXXXXXXXXX`

#request

#responses

post

/subscription

Create a subscription for the current user.

#request

#responses

delete

/subscription/{id}

Cancel a subscription for the current user.

#parameters

idstringID of the subscription to cancel.
example: `sub_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

#Token

GET

/token

list tokens

GET

/token/{id}

get token

POST

/token

create token

DELETE

/token/{id}

delete token

get

/token

List the current user's personal access tokens.

#responses

get

/token/{id}

Get the personal access token with the given ID.

#parameters

idstringID of the personal token to get.
example: `pat_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

post

/token

Create a personal access token.

#responses

delete

/token/{id}

Delete the personal access token with the given ID.

#parameters

idstringID of the personal token to delete.
example: `pat_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

#App (OAuth)

GET

/app

list apps

GET

/app/{id}

get app

POST

/app

create app

DELETE

/app/{id}

delete app

get

/app

List the current user's registered apps.

#responses

get

/app/{id}

Get the app with the given ID.

#parameters

idstringID of the app to get.
example: `cli_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

post

/app

Create an app.

#request

#responses

delete

/app/{id}

Delete the app with the given ID.

#parameters

idstringID of the app to delete.
example: `cli_XXXXXXXXXXXXXXXXXXXXXXXXX`

#responses

#Account

GET

/account/link-email/confirm/{token}

show ssh email link confirmation

POST

/account/link-email

start ssh email linking

POST

/account/link-email/confirm/{token}

confirm ssh email link

#Miscellaneous

GET

/view/init

get app data

POST

/email

subscribe email

public

get

/view/init

Get initial app data, including user, products, cart, addresses, cards, subscriptions, and orders.

#responses

post

/email

public

Subscribe to email updates from Terminal.

#request

#responses