Skip to content
On this page
netzo/apis/shopify

Shopify

Shopify is a complete commerce platform that lets you start, grow, and manage a business. Create and customize an online store, sell in multiple places, and manage integrations with third-party apps. The Admin API lets you build apps and other integrations for your own Shopify store.

  • labels: ecommerce, commerce, shopping-cart, store
  • authentication: apiKey

Usage

ts
import { shopify } from 'https://deno.land/x/netzo/apis/shopify/mod.ts'

const { api } = shopify({
  storeName: Deno.env.get('SHOPIFY_STORE_NAME'),
  apiVersion: Deno.env.get('SHOPIFY_API_VERSION'),
  apiKey: Deno.env.get('SHOPIFY_API_KEY'),
})
import { shopify } from 'https://deno.land/x/netzo/apis/shopify/mod.ts'

const { api } = shopify({
  storeName: Deno.env.get('SHOPIFY_STORE_NAME'),
  apiVersion: Deno.env.get('SHOPIFY_API_VERSION'),
  apiKey: Deno.env.get('SHOPIFY_API_KEY'),
})

Configuration

The shopify factory function expects an object with the following, and returns an object with an HTTP client api.

ParamTypeDefaultDescription
storeNamestringDeno.env.get('SHOPIFY_STORE_NAME')the store name
apiKeystringDeno.env.get('SHOPIFY_API_KEY')the api key to use for authentication
apiVersionstringDeno.env.get('SHOPIFY_API_VERSION')the api version

Refer to the API documentation to get the required information.

Examples

The following examples assume you have created an api client instance. Refer to the type definitions for all exported types to pass to the api client for typed responses.

Find customers

Find all customers that match the query.

ts
import type { Customers, QueryCustomers } from 'netzo/apis/shopify/types.ts'

const query: QueryCustomers = {}
const result = await api['customers.json'].get<Customers>(query)
const resultData = result.customers
import type { Customers, QueryCustomers } from 'netzo/apis/shopify/types.ts'

const query: QueryCustomers = {}
const result = await api['customers.json'].get<Customers>(query)
const resultData = result.customers

Get customer

Get a customer by id.

To limit the search to certain fields, specify a comma-separated list of field names.

ts
import type { Customer } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.customers[`${CUSTOMER_ID}.json`].get<Customer>(fields)
const resultData = result.customer
import type { Customer } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.customers[`${CUSTOMER_ID}.json`].get<Customer>(fields)
const resultData = result.customer

Find customer's orders

Find all orders belonging to a specific customer.

ts
import type { OrderStatus, OrdersByCustomer } from 'netzo/apis/shopify/types.ts'

const query: OrderStatus = 'any'
const result = await api.customers[CUSTOMER_ID]['orders.json'].get<OrdersByCustomer>(query)
const resultData = result.orders
import type { OrderStatus, OrdersByCustomer } from 'netzo/apis/shopify/types.ts'

const query: OrderStatus = 'any'
const result = await api.customers[CUSTOMER_ID]['orders.json'].get<OrdersByCustomer>(query)
const resultData = result.orders

Add customer

Add a new customer.

ts
import type { AddOrUpdateCustomerResult, DataAddOrUpdateCustomer } from 'netzo/apis/shopify/types.ts'

const data: DataAddOrUpdateCustomer = {
  customer: {
    first_name: 'John',
    last_name: 'Doe',
    email: '[email protected]'
  }
}
const result = await api['customers.json'].post<AddOrUpdateCustomerResult>(data)
const resultData = result.customer
import type { AddOrUpdateCustomerResult, DataAddOrUpdateCustomer } from 'netzo/apis/shopify/types.ts'

const data: DataAddOrUpdateCustomer = {
  customer: {
    first_name: 'John',
    last_name: 'Doe',
    email: '[email protected]'
  }
}
const result = await api['customers.json'].post<AddOrUpdateCustomerResult>(data)
const resultData = result.customer

Update customer

Update a customer by id.

ts
import type { AddOrUpdateCustomerResult, DataAddOrUpdateCustomer } from 'netzo/apis/shopify/types.ts'

const data: DataAddOrUpdateCustomer = {
  customer: {
    email: '[email protected]'
  }
}
const result = await api.customers[`${CUSTOMER_ID}.json`].put<AddOrUpdateCustomerResult>(data)
const resultData = result.customer
import type { AddOrUpdateCustomerResult, DataAddOrUpdateCustomer } from 'netzo/apis/shopify/types.ts'

const data: DataAddOrUpdateCustomer = {
  customer: {
    email: '[email protected]'
  }
}
const result = await api.customers[`${CUSTOMER_ID}.json`].put<AddOrUpdateCustomerResult>(data)
const resultData = result.customer

Find orders

Find all orders that match the query.

ts
import type { Orders, QueryOrders } from 'netzo/apis/shopify/types.ts'

const query: QueryOrders = {}
const result = await api['orders.json'].get<Orders>(query)
const resultData = result.orders
import type { Orders, QueryOrders } from 'netzo/apis/shopify/types.ts'

const query: QueryOrders = {}
const result = await api['orders.json'].get<Orders>(query)
const resultData = result.orders

Get order

Get an order by id.

To limit the search to certain fields, specify a comma-separated list of field names.

ts
import type { Order } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.orders[`${ORDER_ID}.json`].get<Order>(fields)
const resultData = result.order
import type { Order } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.orders[`${ORDER_ID}.json`].get<Order>(fields)
const resultData = result.order

Find products

Find all products that match the query.

ts
import type { Products, QueryProducts } from 'netzo/apis/shopify/types.ts'

const query: QueryProducts = {}
const result = await api['products.json'].get<Products>(query)
const resultData = result.products
import type { Products, QueryProducts } from 'netzo/apis/shopify/types.ts'

const query: QueryProducts = {}
const result = await api['products.json'].get<Products>(query)
const resultData = result.products

Get product

Get a product by id.

To limit the search to certain fields, specify a comma-separated list of field names.

ts
import type { Product } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.products[`${PRODUCT_ID}.json`].get<Product>(fields)
const resultData = result.product
import type { Product } from 'netzo/apis/shopify/types.ts'

const query: { fields: string } = {}
const result = await api.products[`${PRODUCT_ID}.json`].get<Product>(fields)
const resultData = result.product

Find payouts

Find all payouts that match the query.

ts
import type { Payouts, QueryPayouts } from 'netzo/apis/shopify/types.ts'

const query: QueryPayouts = {}
const result = await api.shopify_payments['payouts.json'].get<Payouts>(query)
const resultData = result.payouts
import type { Payouts, QueryPayouts } from 'netzo/apis/shopify/types.ts'

const query: QueryPayouts = {}
const result = await api.shopify_payments['payouts.json'].get<Payouts>(query)
const resultData = result.payouts

References