diff --git a/docs/Developers/using-the-API.md b/docs/Developers/using-the-API.md index 466957f5e8..a01ef62cfe 100644 --- a/docs/Developers/using-the-API.md +++ b/docs/Developers/using-the-API.md @@ -31,25 +31,27 @@ Next, you’ll need connect to your running server version of Actual to access y ```js let api = require('@actual-app/api'); -await api.init({ - // Budget data will be cached locally here, in subdirectories for each file. - dataDir: '/some/path', - // This is the URL of your running server - serverURL: 'http://localhost:5006', - // This is the password you use to log into the server - password: 'hunter2', -}); +(async () => { + await api.init({ + // Budget data will be cached locally here, in subdirectories for each file. + dataDir: '/some/path', + // This is the URL of your running server + serverURL: 'http://localhost:5006', + // This is the password you use to log into the server + password: 'hunter2', + }); -// This is the ID from Settings → Show advanced settings → Sync ID -await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f'); -// or, if you have end-to-end encryption enabled: -await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f', { - password: 'password1', -}); + // This is the ID from Settings → Show advanced settings → Sync ID + await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f'); + // or, if you have end-to-end encryption enabled: + await api.downloadBudget('1cfdbb80-6274-49bf-b0c2-737235a4c81f', { + password: 'password1', + }); -let budget = await api.getBudgetMonth('2019-10'); -console.log(budget); -await api.shutdown(); + let budget = await api.getBudgetMonth('2019-10'); + console.log(budget); + await api.shutdown(); +})(); ``` Heads up! You probably don’t want to hard-code the passwords like that, especially if you’ll be using Git to track your code. You can use environment variables to store the passwords instead, or read them in from a file, or request them interactively when running the script instead.