kite-node
v1.0.21
Published
The Kite JavaScript library provides convenient access to the [Kite REST API](https://www.kite.ly/docs/) from applications written in Node. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API response
Downloads
10
Readme
Kite Node.js SDK
The Kite JavaScript library provides convenient access to the Kite REST API from applications written in Node. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
Documentation
See the JavaScript API docs.
Suggested Installation Approach
via NPM
npm install kite-node
Suggested Usage / Approach
After installing the library from NPM you will need to require the library in your project.
const Kite = require('kite-node');
The library needs to be configured with your account's public key which is available in your Kite Dashboard. You may also want to set the optional secret key at this point.
Kite.setPublicKey('replaceWithYourPublicKey');
/* Optional */
Kite.setSecretKey('replaceWithSecretKey');
SDK Features
Address Search / Lookup
Search for an address in a certain country.
If a single matching address is found this is returned, otherwise an array of multiple addresses is returned.
Either search_term or address_id is required.
Kite.address.search({
country_code: "GBR",
search_term: "10 Downing Street" // Optional,
address_id: 'GBR|PR|23747771|0|0|0||Retrieve' // Optional
},
function(uniqueAddress) {...},
function(multipleAddresses) {...},
function(err) {...} // If no address is found
);
/*
If multiple addresses are found, another call needs to be made
to get further details. This can be called directly on the returned
address object
*/
multipleAddresses[0].getDetail(
function(success) {...},
function(err) {...}
);
/* or via the Kite.address.getDetail function */
Kite.address.getDetail(
multipleAddresses[0],
function(address) {...},
function(err) {...}
);
Product Retrieval
/*
Returns a list of products associated with the current Kite account
*/
Kite.product.list({
limit: 50,
offset: 0
},
function(productsResponse) {...},
function(err) {...} // E.g incorrect parametres
);
/* Retrieve a single product by it's template_id */
Kite.product.get(
'i6_case',
function(product) {...},
function(err) {...} // If no product is found
);
Order Retrieval
/*
* Returns a list of orders associated with the Kite account.
*/
Kite.order.list({
limit: 100
},
function(ordersResponse) {...},
function(err) {...} // E.g incorrect parametres
);
/* Retrieve single order by id */
Kite.order.get(
'PS123-12341234',
function(order) {...},
function(err) {...} // If no order is found
);
Placing Product Orders
/*
* Create and submit an order for printing
* 1. Create any print jobs that will be part of the order
*/
var phonecaseJob = Kite.job.create({
template_id:"i6_case",
asset:"http://.../image.jpg",
options:{
case_style:"matte"
}
});
var tshirtJob = Kite.job.create({
template_id:"aa_mens_tshirt",
assets:{
center_chest:"http://.../image.jpg",
center_back:"http://.../image.jpg"
},
options:{
garment_size:"M",
garment_color:"white"
}
});
/* 2. Create the order to which the jobs will be added */
var order = Kite.order.create();
order.jobs.push(phonecaseJob);
order.jobs.push(tshirtJob);
order.shipping_address = ... ; // set it to an Address object
order.promo_code = "XYZ"; // optional
/* optionally view the cost of the order */
var cost = order.calculateCost(function(cost) {...}, function(err) {...});
/* 3. submit the print order to kite for fulfillment */
/*
Either the proof of payment needs to be set or if using
the SDK through NodeJS the secret key can be set instead.
*/
order.proof_of_payment = "..."; // Stripe charge token
order.submit(function(orderId) {...}, function(err) {...});