Node module for accessing the Codat Accounting Data API from your node applications.
You can install this package using the following command:
npm install --save codat
For more information on Codat see www.codat.io
We use a tool called Babel at Codat and can highly recommend it.
Please refer to the tests in the project, they document the usage of the components found in the library.
The API client is a handy object that exposes useful functionality from the Codat public API, as well as helping you make queries against data for linked companies.
// Import the module just like any other node dependancy.;var apiKey = '<YOUR API KEY HERE>';// Use codat.uat for UAT environment.var codatApiUat = codat;var codatApi = codatapiKey;// Use whichever method suits your build pipleine the best.codatApiUat === codatApi;// Use codat.production for Production environment.var codatApiUat = codat;var codatApi = codatapiKey;// The common datasets are listed in constant data.var datasets = codatconstantsdatasets;
When you want to intereact directly with your linked companies you can use the helper method exposed by the API client.
This set of features allows you to:
addCompany- Add companies.
removeCompany- Remove companies.
updateCompany- Update companies.
getCompany- Get information about a specific company.
getCompanies- Query for all currently linked companies.
// Add a new companycodatApi;// Fetch list of all linked companiescodatApi;
When you want to get hold of data for a specific company you can use one of the given query objects. These query objects make building reuseable queries much easier as they specify the specific parameters for filters that you might want to use.
;var companyId = 'ff36ff03-17de-47be-883a-5ceecbbc65ed';// Build a reusable query object.// The query objects help you specify any query parameters.var balanceSheetQuery = companyId 1 3 ;// Run the query using your codatApi client.balanceSheetQuery;
You can use the company data api client to build your own queries without the query objects and specifiy the arguments yourself.
In fact this is what the query objects use under the hood!
var companyId = 'ff36ff03-17de-47be-883a-5ceecbbc65ed';// You can also roll your own queries to the data api.// Be aware some query parameters are not availble on all endpoints.var companyClient = codatApi;// You can do this with a new company data client from the api clientcompanyClient;
If you need to refresh the data for a given company on demand, you cann use the provided refresh extensions and run them using the
codatApiClient just like you can with the queries.
NOTE: Please be aware this functionality is not currently supported by Codat's 'Sage 50' platform connection.
;var companyId = 'ff36ff03-17de-47be-883a-5ceecbbc65ed';// Build a reusable refresh object.var refreshAllDatasets = companyId;// Run the query using your codatApi client.refreshAllDatasets;