Swish Developer Docs
Go to websiteInstall now
  • Swish API
    • Overview
    • Authentication
    • Rate limits
    • Pagination
    • Errors
    • API Reference
      • Items
      • Lists
      • Profiles
  • Libraries
    • API Client
    • Browser
    • Node.js
    • React
Powered by GitBook
On this page
  • Requirements
  • Installation
  • Usage
  • Reference
  • Items
  • Lists
  • Profiles
  1. Libraries

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.

When integrating Swish into a browser environment, using the Browser library is recommended.

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

For more details, refer to the Items API reference.

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

For more details, refer to the Lists API reference.

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

For more details, refer to the Profiles API reference.

Create new token

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

PreviousProfilesNextBrowser

Last updated 2 months ago