The dist/browser/ynab.js file (located in node_modules/ynab after installation) is specifically built to run in a browser / window context and exports ynab variable to global namespace. No other dependencies are needed.
<script src="ynab.js" async></script>...<script> // This assignment is not necessary but demonstrates that // once the library is loaded, the global 'ynab' object will be available. var ynab = window.ynab;</script>
CDN
A simple way to load the library in a browser is by using the unpkg CDN, which is a
"fast, global content delivery network for everything on npm". To use it, include a script tag like this in your file:
Using the "latest" tag will result in a 302 redirect to the latest version tag so it is highly recommended to use a specific version tag such as https://unpkg.com/ynab@1.5.0/dist/browser/ynab.js to avoid this redirect.
There are several utilities available on the utils export to make working
with ISO dates and milliunits a bit
easier.
// Returns the current month (system timezone) in ISO 8601 format (i.e. '2015-12-01')utils.getCurrentMonthInISOFormat(): string;// Returns the current date (system timezone) in ISO 8601 format (i.e. '2015-12-15')utils.getCurrentDateInISOFormat(): string;// Converts an ISO 8601 formatted string to a JS date objectutils.convertFromISODateString(isoDateString: string): Date;// Converts a milliunits amount to a currency amountutils.convertMilliUnitsToCurrencyAmount(milliunits: number, currencyDecimalDigits: number): number;
Versioning
The version of this client is defined in the package.json file and follows semantic versioning. The version of this client is maintained independently and does not align with the the version of YNAB API itself (which is defined in the OpenAPI spec). To determine which spec version of the YNAB API was used when generating this client you can refer to the "description" field in the package.json file.