Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shopify-node

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shopify-node

A NodeJS connector for Shopify OAuth2

  • 0.1.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Shopify Node

npm install shopify-node

You can run the test by cloning this repo and running:

npm install
node test/test

For setting up:

var shopifyObj = require('shopify-node');

var shopify = new shopifyObj({
	shop_name: 'typefoo',
	id: '639e5b59d03a4135d4f4cd176d8b0d0c',
	secret: '07e3e4d5711054ead625ac7356552660',
	redirect: 'http://localhost:9000/#/oauth'
	// scope: 'write_products', as an example. The default scope has access to all.
	// For more on scopes: http://docs.shopify.com/api/tutorials/oauth
});

var url = shopify.createURL();

After you have obtained the 'code' (either via your redirect or elsewhere):

var code = ''; // put the short-time auth code in here.

shopify.getAccessToken(code, function(err, access_token) {
	console.log(err);
	console.log(access_token);
});

If you have saved your access token in some sort of session or cookie data, you can skip the authorization request:

var shopify = new shopifyObj({
	shop_name: 'typefoo',
	id: '639e5b59d03a4135d4f4cd176d8b0d0c',
	secret: '07e3e4d5711054ead625ac7356552660',
	redirect: 'http://localhost:9000/#/oauth',
	access_token: '' // your access token to be used
});

Once authorized, you can perform typical REST services (http://docs.shopify.com/api/ for reference):

// GET
shopify.get('/admin/orders.json', function(err, resp) {
  if(err) {
    return console.log(err);
  }
  console.log(resp);
});

// POST
var postData = {
  product: {
    title: 'Burton Custom Freestlye 151',
    body_html: '<strong>Good snowboard!</strong>',
    vendor: 'Burton',
    product_type: 'Snowboard',
    variants: [
      {
        option1: 'First',
        price: '10.00',
        sku: 123
      },
      {
        option1: 'Second',
        price: '20.00',
        sku: '123'
      }
    ]
  }
};
shopify.post('/admin/products.json', postData, function(err, resp) {
  if(err) {
    return console.log(err);
  }
  console.log(resp);
});

// PUT
shopify.put('/admin/products/1234.json', postData, function(err, resp) {
  if(err) {
    return console.log(err);
  }
  console.log(resp);
});

// DELETE
shopify.delete('/admin/products/1234.json', function(err, resp) {
  if(err) {
    return console.log(err);
  }
  console.log(resp);
});

Built in Carolina & Ohio. www.typefoo.com

FAQs

Package last updated on 29 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc