Example Application - Invoices
Complete the steps described in the rest of this page to create a simple Node application demonstrating the simplest way to connect to Boss insights API.
What you will need:
Boss insights account
Latest version of NodeJS https://nodejs.org/en/
Follow-redirects module(in same directory as your project run the command “nmp i follow-redirects” in your terminal).
Create a simple node application connecting to balance sheet endpoint
We will create a simple application demonstrating the fastest and simplest way to get up and running with our API using the balance sheet endpoint.
The fastest way to get started is by visiting https://api.bossinsights.com/ and select which endpoint you would like to connect to.
On the right hand side of the screen you will see some example code to make a request to the API.
Create a folder and in that folder we will create a file called balanceSheet.js.
In balanceSheet.js we will include the following code. You will have to fill in “auth” with your username and password, and hostname with the correct URL where “myCompanyName“ is your company name.
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
auth: "username:password", // replace with your username and password
protocol: "https:",
method: "GET",
hostname: "myCompanyName.myintranetapps.com", //Replace mycompanyName with your company name
path: '/api/balance_sheets?start=2021-01-01end=2021-03-31&accounting_method=accrual&page=1',
headers: {
},
'maxRedirects': 20,
port: "443", // may not be needed
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
Parameter | Definition |
---|---|
| auth is your username and password for your account. where username will be replaced by your username and password will be replaced with your password |
| The protocol that will be used is https |
| method is GET |
| Host name will be “myCompanyName.myintranetapps.ca” or “myCompanyName.myintranetapps.com”, where myCompanyName will be replaced with your company name. |
| In this case the path is |
5. Run the command “node balanceSheet.js” in your terminal assuming you are in the same directory as balanceSheet.js.
6. The Result will be a JSON object that is a bit messy to read. The result will look like:
{
"id": "quickbooks-10",
"additionalType": null,
"category": null,
"confirmationNumber": null,
"customerId": "2",
"paymentMethod": null,
"paymentMethodId": null,
"paymentDueDate": "2020-11-27T00:00:00+00:00",
"provider": null,
"potentialAction": null,
"broker": null,
"minimumPaymentDue": null,
"accountId": null,
"scheduledPaymentDate": null,
"billingPeriod": null,
"paymentStatus": null,
"created": "2021-02-09T22:57:16+00:00",
"modified": "2021-02-11T20:56:01+00:00",
"subtotal": 17500,
"taxAmount": 0,
"currencyCode": "USD",
"invoiceNumber": "1002",
"amountPaid": null,
"amountCredited": null,
"customerName": "Bill's Windsurf Shop",
"customerMemo": "Thank you for your business and have a great day!",
"billingEmail": "Surf@Intuit.com",
"billingAddressType": null,
"billingAddressLine1": "Bill Lucchini",
"billingAddressLine2": "Bill's Windsurf Shop",
"billingCity": null,
"billingPostalCode": null,
"shippingAddressType": null,
"shippingAddressLine1": null,
"shippingAddressLine2": null,
"shippingCity": null,
"shippingPostalCode": null,
"srcId": "10",
"url": null,
"status": null,
"txnDate": "2020-10-28T00:00:00+00:00",
"jsonAddress": "Bill Lucchini, Bill's Windsurf Shop, 12 Ocean Dr., Half Moon Bay, CA 94213",
"subscriptionId": null,
"referenceNumber": null,
"balance": 0,
"accountName": null,
"purchaseOrderNum": null,
"billingCountry": null,
"totalAmount": 17500,
"billingState": null,
"shippingCountry": null,
"shippingState": null
},
{
"id": "quickbooks-103",
"additionalType": null,
"category": null,
"confirmationNumber": null,
"customerId": "10",
"paymentMethod": null,
"paymentMethodId": null,
"paymentDueDate": "2021-03-13T00:00:00+00:00",
"provider": null,
"potentialAction": null,
"broker": null,
"minimumPaymentDue": null,
"accountId": null,
"scheduledPaymentDate": null,
"billingPeriod": null,
"paymentStatus": null,
"created": "2021-02-11T21:41:59+00:00",
"modified": "2021-02-11T21:42:08+00:00",
"subtotal": 58250,
"taxAmount": 4660,
"currencyCode": "USD",
"invoiceNumber": "1033",
"amountPaid": null,
"amountCredited": null,
"customerName": "Geeta Kalapatapu",
"customerMemo": "Thank you for your business and have a great day!",
"billingEmail": "Geeta@Kalapatapu.com",
"billingAddressType": null,
"billingAddressLine1": "Geeta Kalapatapu",
"billingAddressLine2": "1987 Main St.",
"billingCity": null,
"billingPostalCode": null,
"shippingAddressType": null,
"shippingAddressLine1": "1987 Main St.",
"shippingAddressLine2": null,
"shippingCity": "Middlefield",
"shippingPostalCode": "94303",
"srcId": "103",
"url": null,
"status": null,
"txnDate": "2021-02-11T00:00:00+00:00",
"jsonAddress": "Geeta Kalapatapu, 1987 Main St., Middlefield, CA 94303",
"subscriptionId": null,
"referenceNumber": null,
"balance": 62910,
"accountName": null,
"purchaseOrderNum": null,
"billingCountry": null,
"totalAmount": 62910,
"billingState": null,
"shippingCountry": null,
"shippingState": null
}
Completing the steps above is the fastest way to connect to one of our endpoints. In this example we looked at one endpoint. We will also be connecting to the invoices endpoint in the next part of this tutorial to give another quick example of how you can connect our end points.
2. Connecting to invoices endpoint
Now we will be performing similar steps to those listed above to connect to the invoices endpoint. This end point will be a little different to connect to as it does no require as many parameters is the path.
In the same directory as balnceSheet.js create a file called invoices.js. You may also create another directory and place it there if you wish.
Once you have created the file you can copy and paste the following code into the the file invoices.js.
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
auth: "username:password", //Replace with your username and password
protocol: "https:",
method: 'GET',
hostname: 'myCompanyName.myintranetapps.com', //Replace myCompanyName with your company name
path: '/api/invoices?page=1',
headers: {
},
maxRedirects: 20,
port: "443", // may not be needed
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
Parameter | Definition |
---|---|
| auth is your username and password for your account. where username will be replaced by your username and password will be replaced with your password |
| The protocol that will be used is https |
| method is GET |
| Host name will be “myCompanyName.myintranetapps.ca” or “myCompanyName.myintranetapps.com”, where myCompanyName will be replaced with your company name. |
| In this case the path is |
3. run the command node invoices.js in your terminal assuming you are in the same directory as invoices.js
4. The result will be a JSON object:
Now that you have successfully completed these steps you should have been able to connect to the two different endpoints and should give you an idea of how to connect to our other various endpoints. What you can do with the data is all up to you and the requirements of your application.