API Client

Lightweight JS client for the Swish REST API.

The Swish API Client provides type-save methods for developers to interact with the API.

Requirements

This packages works in all JS environments were the fetch API is available.

Installation

npm install @swishapp/api-client

Usage

import { createApiClient } from "@swishapp/api-client";

const swish = createApiClient({
  authToken: "your-api-auth-token"
});

const { data } = await swish.items.list();

Reference

Items

List all items

const { data, error } = await swish.items.list();

List all items (pagination)

const { data, error } = await swish.items.list({
  page: "page-cursor",
  limit: 20,
});

List all items (search query)

const { data, error } = await swish.items.list({
  query: "product:123",
});

Create new item

const { data, error } = await swish.items.create({ 
  productId: 123, variantId: 456, quantity: 1,
});

Delete multiple items

const { error } = await swish.items.delete([
  "item-id-1",
  "item-id-2",
]);

Find item by ID

const { data, error } = await swish.items.findById("item-id");

Update item by ID

const { data, error } = await swish.items.updateById("item-id", {
  variantId: 456,
});

Delete item by ID

const { error } = await swish.items.deleteById("item-id");

Lists

List all lists

const { data, error } = await swish.lists.list();

Create new list

const { data, error } = await swish.lists.create({
  name: "Favourites",
});

Find list by ID

const { data, error } = await swish.lists.findById("list-id");

Find list by ID (items sorted in custom order)

const { data, error } = await swish.lists.findById("list-id", {
  sort: "customer"
});

Update list by ID

const { data, error } = await swish.lists.updateById("list-id", {
  name: "New list name",
});

Delete list by ID

const { error } = await swish.lists.deleteById("list-id");

Set custom item order

const { data, error } = await swish.lists.orderItems("list-id", {
  itemIds: ["item-id-2", "item-id-1"],
});

Profiles

Create new token

const { data, error } = await swish.profiles.createToken({
  customer: "gid://shopify/Customer/1234567",
})

Last updated