npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rye-api/rye-sdk

v1.4.2

Published

SDK for the Rye API

Downloads

106

Readme

Rye SDK

The Rye SDK provides convenient access to the Rye API via the Rye client from which users can make queries and mutations easily.

Installation

Install the package with:

npm install @rye-api/rye-sdk
# or
yarn add @rye-api/rye-sdk
# or
pnpm add @rye-api/rye-sdk

Usage

Client creation

The client needs to be created with your account's API authorization header and Shopper IP, which is available in the Rye Console.

// Production
const ryeClient = new RyeClient({
  authHeader: '<AUTH_HEADER>',
  shopperIp: '<SHOPPER_IP>',
});

// Staging
const ryeClient = new RyeClient({
  authHeader: '<AUTH_HEADER>',
  shopperIp: '<SHOPPER_IP>',
  environment: ENVIRONMENT.STAGING,
});

Mutations

  1. requestProductByURL
const result = await ryeClient.requestProductByUrl({
  input: {
    url: 'https://www.amazon.com/dp/B00A2KD8NY',
    marketplace: Marketplace.Amazon,
  },
});
  1. requestStoreByURL
const result = await ryeClient.requestStoreByURL({
  input: {
    url: 'https://rye-test-store.myshopify.com',
  },
});
  1. createCart
// Create cart without buyer identity
const result = await ryeClient.createCart({
  input: {
    items: {
      amazonCartItemsInput: [
        {
          quantity: 1,
          productId: 'B007W3DDUW',
        },
      ],
    },
    buyerIdentity: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
});

// Create cart with buyer identity
const result = await ryeClient.createCart({
  input: {
    items: {
      amazonCartItemsInput: [
        {
          quantity: 1,
          productId: 'B007W3DDUW',
        },
      ],
    },
  },
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. addCartItems
const result = await ryeClient.addCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      shopifyCartItemsInput: [
        {
          quantity: 1,
          variantId: '44346795295022',
        },
      ],
    },
  },
});
  1. deleteCartItems
const result = await ryeClient.deleteCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      shopifyProducts: [
        {
          variantId: '44346795295022',
        },
      ],
    },
  },
});
  1. updateCartItems
const result = await ryeClient.updateCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      amazonCartItemsInput: [
        {
          productId: 'B007W3DDUW',
          quantity: 2,
        },
      ],
    },
  },
});
  1. updateCartBuyerIdentity
const result = await ryeClient.updateCartBuyerIdentity({
  input: {
    id: '<CART_ID>',
    buyerIdentity: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. updateCartSelectedShippingOptions
const result = await ryeClient.updateCartSelectedShippingOptions({
  input: {
    id: '<CART_ID>',
    shippingOptions: [
      {
        shippingId: '55cfdaa8c7702fb7f57be90',
        store: 'rye-dev-store.myshopify.com',
      },
    ],
  },
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. submitCart
const result = await ryeClient.submitCart({
  input: {
    id: '<CART_ID>',
    token: '<PAYMENT_TOKEN>',
    billingAddress: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
});
  1. removeCart
const result = await ryeClient.removeCart({
  input: {
    id: '<CART_ID>',
  },
});

Queries

  1. productByID
const result = await ryeClient.getProductById({
  input: {
    id: 'B007W3DDUW',
    marketplace: 'AMAZON',
  },
});
  1. productsByDomainV2
const result = await ryeClient.getProductsByDomainV2({
  input: {
    domain: 'hiutdenim.co.uk',
  },
  pagination: { limit: 3, offset: 2 },
});
  1. getCart
const result = await ryeClient.getCart({
  id: '<CART_ID>',
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. orderByID
const result = await ryeClient.orderById({
  id: '<ORDER_ID>',
});
  1. checkoutByCartID
const result = await ryeClient.checkoutByCartId({
  id: '<CART_ID>',
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. shopifyApp
const result = await ryeClient.getShopifyAppInformation({
  storeCanonicalDomain: 'dear-media-shop.myshopify.com',
});
  1. environmentToken
const result = await ryeClient.getEnvironmentToken();

Additional resources

  • Documentation: https://docs.rye.com/
  • Rye Console: https://console.rye.com/
  • Tutorial: https://tutorial.rye.com/
  • Website: https://rye.com/
  • Contact us at: [email protected]