Please read the YNAB API documentation for an overview of using the API and a complete list of available resources.
This client is generated using the Swagger Code Generator.
First, install the module with npm (or yarn):
npm install ynab
Then, depending upon your usage context, add a reference to it:
CommonJS / Node
const ynab = require("ynab");
ESM / TypeScript
import * as ynab from "ynab";
The API supports Cross Origin Resource Sharing (CORS) for asynchronous browser requests from any origin.
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>
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:
<script src="https://unpkg.com/ynab@latest/dist/browser/ynab.js" async></script>
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://firstname.lastname@example.org/dist/browser/ynab.js to avoid this redirect.
If a response is returned with a code >= 300, instead of returning the response, the response will be thrown as an error to be caught.
See the examples folder for example usage scenarios.
The following methods are available in this library. For more details on parameters and usage, the TypeScript declaration file can be referenced.
There are several utilities available on the
utils export to make working
with ISO dates and milliunits a bit
// Returns the current month (system timezone) in ISO 8601 format (i.e. '2015-12-01')getCurrentMonthInISOFormat: string;// Returns the current date (system timezone) in ISO 8601 format (i.e. '2015-12-15')getCurrentDateInISOFormat: string;// Converts an ISO 8601 formatted string to a JS date objectconvertFromISODateStringisoDateString: string: Date;// Converts a milliunits amount to a currency amountconvertMilliUnitsToCurrencyAmountmilliunits: number, currencyDecimalDigits: number: number;
- Install dependencies:
- Generate latest client based on swagger spec:
npm run generate
- Run tests:
- Publish to npm:
npm run release
Copyright (c) 2018 You Need A Budget, LLC
Licensed under the Apache-2.0 license