All Projects → moltin → moltin-request

moltin / moltin-request

Licence: MIT license
🎮 Minimal Elastic Path Commerce Cloud API request library for Node

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to moltin-request

ios-sdk
Swift SDK for the Moltin eCommerce API
Stars: ✭ 35 (+105.88%)
Mutual labels:  ecommerce, moltin
react-moltin-ecommerce
[DEPRECIATED] React based Moltin API ecommerce implementation
Stars: ✭ 30 (+76.47%)
Mutual labels:  ecommerce, moltin
dress-shop
A full stack server side rendered e-commerce built with Next.js, TypeScript, Node.js, Express and MongoDB.
Stars: ✭ 164 (+864.71%)
Mutual labels:  ecommerce
commercetools-sync-java
Java library for importing and syncing (taking care of changes) data into one or more commercetools projects from external data files or from another commercetools project.
Stars: ✭ 26 (+52.94%)
Mutual labels:  ecommerce
magento2-freeshipping-progress-bar
Add a free shipping eligibility progress bar to your Magento 2 websites cart to promote increased order value.
Stars: ✭ 37 (+117.65%)
Mutual labels:  ecommerce
headstart
A complete and opinionated eCommerce solution using OrderCloud as the backbone - built with .NET Core and Angular
Stars: ✭ 28 (+64.71%)
Mutual labels:  ecommerce
Shopping-Cart-MERN
💸 Simple Online Shopping Cart made with the MERN Stack
Stars: ✭ 34 (+100%)
Mutual labels:  ecommerce
retailbox
🛍️RetailBox - eCommerce Recommender System using Machine Learning
Stars: ✭ 32 (+88.24%)
Mutual labels:  ecommerce
MyOOS
MyOOS [Shop system] Repository
Stars: ✭ 26 (+52.94%)
Mutual labels:  ecommerce
spartacus-capybara
SAP Spartacus Theme based on https://storefrontui.io look and feel and design system. Headless storefront solution for Hybris. Always Open Source, MIT license. Made with 💙 by Divante
Stars: ✭ 44 (+158.82%)
Mutual labels:  ecommerce
core-next
core-next microservice framework
Stars: ✭ 14 (-17.65%)
Mutual labels:  ecommerce
shop-acai
🍇 Full stacks de um sistema de açai simples para estudos
Stars: ✭ 18 (+5.88%)
Mutual labels:  ecommerce
magento-2-pronko-consulting-theme
Pronko Consulting Theme for Magento 2
Stars: ✭ 47 (+176.47%)
Mutual labels:  ecommerce
awesome-medusajs
A curated list of awesome resources related to MedusaJS 😎
Stars: ✭ 113 (+564.71%)
Mutual labels:  ecommerce
mern-ecommerce
MERN Stack ecommerce site
Stars: ✭ 122 (+617.65%)
Mutual labels:  ecommerce
production
Shopware 6 production template
Stars: ✭ 156 (+817.65%)
Mutual labels:  ecommerce
FoodDelivery
E-Commerce demo project. Food delivery application project made with.
Stars: ✭ 106 (+523.53%)
Mutual labels:  ecommerce
grandnode2
Free, Open source, Fast, Headless, Multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB, Vue.js.
Stars: ✭ 626 (+3582.35%)
Mutual labels:  ecommerce
taxjar.net
Sales Tax API Client for .NET / C#
Stars: ✭ 21 (+23.53%)
Mutual labels:  ecommerce
v-shopware-api-client
The reliable way to import and update a bazillion products.
Stars: ✭ 20 (+17.65%)
Mutual labels:  ecommerce

Elastic Path Commerce Cloud @moltin/request

npm version semantic-release code style: prettier License: MIT contributions welcome follow on Twitter

🎮 Minimal Elastic Path Commerce Cloud API request library for Node

Examples · API Reference

Installation

yarn add @moltin/request # npm install @moltin/request

Quickstart (implicit)

const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'

const client = new MoltinClient({
  client_id: '...'
})

client
  .get('products')
  .then(console.log)
  .catch(console.error)

Quickstart (client credentials)

⚠️ You should not use client credentials on the client-side. You will expose your client secret, read more about authentication here.

const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'

const client = new MoltinClient({
  client_id: '...',
  client_secret: '...'
})

client
  .post('brands', {
    name: 'My Special Brand',
    slug: 'my-special-brand',
    status: 'live'
  })
  .then(console.log)
  .catch(console.error)

client
  .put('brands/:id', {
    name: 'My Special Brand!'
  })
  .then(console.log)
  .catch(console.error)

client
  .delete('brands/:id')
  .then(console.log)
  .catch(console.error)

Quickstart (with storage)

To prevent unnecessary authentication requests, you will want to use a storage adapter.

Node Local Storage

const { MoltinClient } = require('@moltin/request')
const NodeStorageAdapter = require('@moltin/node-storage-adapter')

const client = new MoltinClient({
  client_id: '...',
  storage: new NodeStorageAdapter('./localStorage')
})

client
  .get('products')
  .then(console.log)
  .catch(console.error)

window.localStorage

const { MoltinClient } = require('@moltin/request')

class LocalStorageAdapter {
  set(key, value) {
    return window.localStorage.setItem(key, value)
  }

  get(key) {
    return window.localStorage.getItem(key)
  }

  delete(key) {
    return window.localStorage.removeItem(key)
  }
}

const client = new MoltinClient({
  client_id: '...',
  storage: new LocalStorageAdapter()
})

client
  .get('products')
  .then(console.log)
  .catch(console.error)

Quickstart (with custom fetch)

This library uses cross-fetch to make requests. If you wish to change this library, you can pass a custom fetch when instantiating a new moltin client.

const { MoltinClient } = require('@moltin/request')
const fetchEverywhere = require('fetch-everywhere')

const client = new MoltinClient({
  client_id: '...',
  fetch: fetchEverywhere
})

client
  .get('products')
  .then(console.log)
  .catch(console.error)

Kitchen sink

const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'

const client = new MoltinClient({
  client_id: '...',
  client_secret: '...',
  fetch: customFetch,
  storage: new NodeStorageAdapter('./moltin'),
  host: '...',
  version: '...',
  application: '...',
  currency: '...',
  customer_token: '...',
  headers: {
    // ...
  }
})

Custom headers per request

The Elastic Path Commerce Cloud API provides you the ability to send various request headers that change the way data is stored or retrieved.

By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type header as an additional argument to get, post, put and delete.

This argument can be used to get products by enabled currency, language or even use for uploading files to Elastic Path Commerce Cloud.

Note: If you add the Content-Type custom header to post, put or delete you will need to encode data yourself.

const { MoltinClient } = require('@moltin/request')

const client = new MoltinClient({
  client_id: '...'
})

const headers = {
  'X-Moltin-Currency': 'gbp'
}

client
  .get('products', headers)
  .then(console.log)
  .catch(console.error)

Terms And Conditions

  • Any changes to this project must be reviewed and approved by the repository owner. For more information about contributing, see the Contribution Guide.
  • For more information about the license, see MIT License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].