shopnode provides a complete, well-documented library for communicating with the powerful shopping cart platform shopify.
The code builds on nodeify using restify in the backend for performance and logging functionality.
- Complete support for the latest shopify api (let me know if it's missing something)
- Uses the Restify module behind the scenes
- Documentation (a work in progress)
- Example code
var Shopnode = require('shopnode');
// Basic Authentication
var shopnode = new Shopnode({
storeHost:'yourshop.myshopify.com',
apiKey:'your-api-key',
password:'your-password-if-basic-auth',
useBasicAuth:true
});
// OAuth 2.0
var shopnode = new Shopnode({
storeHost:'yourshop.myshopify.com',
apiKey:'your-api-key',
sharedSecret:'your-shared-key'
});
- storeHost - the store url without the https
- apiKey - the key found in the admin section of your store
- password - for private apps, this will be available. Public apps must used
- sharedKey - for apps using OAuth 2.0, a shared key is required
Before making an api call, it's important to read and understand the Shopify Api. The POST/PUT/GET/DELETE methods all have specific parameters for each.
shopnode.webhooks.getAll(function (err, req, res, obj) {
assert.ifError(err);
console.log('Server returned: %j', obj.body);
});
shopnode.orders.get({id: 12345}, {/* Empty query string */},
function (err, req, res, obj) {
assert.ifError(err);
console.log('Server returned: %j', obj.body);
});
shopnode.customers.post({
"customer": {
"first_name": "Steve",
"last_name": "Lastnameson",
"email": "steve.lastnameson@lastnamesonco.com",
"addresses": [
{
"address1": "123 Oak St",
"city": "Ottawa",
"country": "CA",
"first_name": "Mother",
"last_name": "Lastnameson",
"phone": "555-1212",
"province": "ON",
"zip": "123 ABC"
}
]
}
},function(err, req, res, obj){
assert.ifError(err);
console.log('Server returned: %j', obj.body);
});
Many resources support basic CRUD operations and have the following signatures:
post(params (optional), data, callback); put(params, data, callback); get(params, queryString, callback); getAll(params (optional), queryString (optional), callback);
- params is an object which will be used to the generate url
- data is an object which will be seralized in all post and put calls
- queryString is an object which will be converted into a query string (i.e. ?name=value&name2=value2)
- Shopify Api - Browse the api
- Shopify Partner Program - Register to become a partner to publish your app to the store.