|
| 1 | +# UniRate for Google Sheets |
| 2 | + |
| 3 | +`=UNIRATE("USD","EUR")` — live currency rates, historical lookups, and EU/UK |
| 4 | +VAT rates as Sheets formulas, backed by the [UniRate API](https://unirateapi.com). |
| 5 | + |
| 6 | +> Get a free API key at [unirateapi.com/signup](https://unirateapi.com/signup) (1,000 requests/day, no card). |
| 7 | +
|
| 8 | +## Functions |
| 9 | + |
| 10 | +| Formula | Returns | |
| 11 | +|---|---| |
| 12 | +| `=UNIRATE("USD","EUR")` | Live rate, 1 USD → ? EUR. | |
| 13 | +| `=UNIRATE("USD","EUR",100)` | 100 USD converted at the live rate. | |
| 14 | +| `=UNIRATE("USD","EUR",100,"2024-01-15")` | Historical conversion (Pro). | |
| 15 | +| `=UNIRATE_RATES("USD")` | All current rates against USD as a 2-column array. | |
| 16 | +| `=UNIRATE_HISTORICAL("2024-01-15","USD")` | All historical rates for a date (Pro). | |
| 17 | +| `=UNIRATE_TIMESERIES("2024-01-01","2024-01-31","USD","EUR,GBP")` | Date × currency rate matrix (Pro). | |
| 18 | +| `=UNIRATE_CURRENCIES()` | Single-column list of supported currency codes. | |
| 19 | +| `=UNIRATE_VAT()` / `=UNIRATE_VAT("DE")` | EU/UK VAT — full table or a single rate. | |
| 20 | + |
| 21 | +The 4-arg historical form, `UNIRATE_HISTORICAL`, and `UNIRATE_TIMESERIES` |
| 22 | +require a UniRate Pro plan; without one they return a clear "Pro plan" |
| 23 | +message in the cell tooltip rather than a silent error. |
| 24 | + |
| 25 | +Currency codes are case-insensitive and trimmed. Dates accept either a |
| 26 | +`YYYY-MM-DD` string or a Sheets date cell. |
| 27 | + |
| 28 | +## Install (end users) |
| 29 | + |
| 30 | +> A Workspace Marketplace listing is in OAuth verification. Until that |
| 31 | +> goes live, install via "Test as add-on" or by copying the script. |
| 32 | +
|
| 33 | +1. Open a Google Sheet. |
| 34 | +2. **Extensions → Apps Script**. |
| 35 | +3. Replace `Code.gs` with the contents of `src/Code.js`. |
| 36 | +4. Add a new file `Setup.gs` with the contents of `src/Setup.js`. |
| 37 | +5. Add a new HTML file `Sidebar` with the contents of `src/Sidebar.html`. |
| 38 | +6. Open `appsscript.json` (gear icon → "Show appsscript.json") and replace |
| 39 | + it with `src/appsscript.json`. |
| 40 | +7. Save, refresh the sheet, accept the OAuth prompt. |
| 41 | +8. **Extensions → UniRate → Set API key…** — paste your key and save. |
| 42 | +9. Try `=UNIRATE("USD","EUR")` in any cell. |
| 43 | + |
| 44 | +## Develop |
| 45 | + |
| 46 | +Local mock tests run under Node — no Apps Script account required. |
| 47 | + |
| 48 | +```bash |
| 49 | +npm install |
| 50 | +npm test # 30 jest tests, no network |
| 51 | +``` |
| 52 | + |
| 53 | +The Apps Script source itself is pushed via [`clasp`](https://github.com/google/clasp): |
| 54 | + |
| 55 | +```bash |
| 56 | +npx clasp login |
| 57 | +npx clasp create --type sheets --rootDir src --title "UniRate for Sheets" |
| 58 | +# clasp writes ./.clasp.json with your scriptId — keep it gitignored. |
| 59 | +npx clasp push |
| 60 | +``` |
| 61 | + |
| 62 | +`.claspignore` keeps tests, `node_modules`, and CI config out of the |
| 63 | +deployable. Only `src/` is shipped. |
| 64 | + |
| 65 | +## Caching and quota |
| 66 | + |
| 67 | +Each successful API call is cached in [`CacheService`](https://developers.google.com/apps-script/reference/cache/cache-service) |
| 68 | +for 1 hour (current rates) or 6 hours (historical and currency-list lookups). |
| 69 | +A sheet with hundreds of `=UNIRATE("USD","EUR")` formulas fans out to one |
| 70 | +HTTP call per hour, so a free-tier key handles realistic load. |
| 71 | + |
| 72 | +## Marketplace listing — submission checklist |
| 73 | + |
| 74 | +This add-on is set up to be published to the Google Workspace Marketplace. |
| 75 | +Steps left, all of which require clicks in the Google Cloud Console: |
| 76 | + |
| 77 | +1. **GCP project** — create one at <https://console.cloud.google.com/projectcreate>. |
| 78 | + Pick a name like `unirate-sheets-addon`. |
| 79 | +2. **OAuth consent screen** — APIs & Services → OAuth consent screen. |
| 80 | + - User type: **External**. |
| 81 | + - App name: `UniRate for Sheets`. |
| 82 | + - Support email: `admin@unirateapi.com`. |
| 83 | + - App logo: upload `marketplace/icon-128.png`. |
| 84 | + - Developer contact: `admin@unirateapi.com`. |
| 85 | + - Authorized domains: `unirateapi.com`. |
| 86 | + - Scopes — add the three from `src/appsscript.json`: |
| 87 | + - `…/auth/script.external_request` |
| 88 | + - `…/auth/script.container.ui` |
| 89 | + - `…/auth/spreadsheets.currentonly` |
| 90 | + - Optional/test users → leave empty (we want public). |
| 91 | +3. **Switch the Apps Script project to this GCP project** — |
| 92 | + Apps Script editor → Project Settings → "Change project" → enter the |
| 93 | + GCP project number from step 1. |
| 94 | +4. **Enable Marketplace SDK** — APIs & Services → Library → search for |
| 95 | + "Google Workspace Marketplace SDK" → Enable. |
| 96 | +5. **Configure the Marketplace listing** — IAM & Admin → Marketplace SDK → |
| 97 | + Configuration / App listing tabs: |
| 98 | + - Application icon: 128×128 PNG. |
| 99 | + - Banner: 220×140 PNG. |
| 100 | + - Screenshots: 1280×800 PNG (3–5 of them; placeholders in `marketplace/`). |
| 101 | + - Privacy policy: `https://unirateapi.com/privacy`. |
| 102 | + - Terms of service: `https://unirateapi.com/terms`. |
| 103 | + - Detailed description: copy from `marketplace/listing-description.md`. |
| 104 | +6. **Verify domain** — Search Console → add `unirateapi.com` if not already. |
| 105 | +7. **Submit for OAuth verification** — OAuth consent screen → Publish app → |
| 106 | + "Prepare for verification". Google asks for: |
| 107 | + - Justification per scope (we use only the three above; copy reasoning |
| 108 | + from `marketplace/oauth-justifications.md`). |
| 109 | + - A demo video of the install + key-entry + one formula evaluation, |
| 110 | + ≤ 2 min, captioned. |
| 111 | + - Domain ownership confirmation (already done in step 6). |
| 112 | +8. **Submit for Marketplace publish** — Marketplace SDK → Publish. |
| 113 | + Listing review and OAuth verification run in parallel; both typically |
| 114 | + take 1–2 weeks. |
| 115 | + |
| 116 | +While verification is pending the script can still be installed by hand |
| 117 | +(see "Install" above). The OAuth grant warns "unverified app" until |
| 118 | +Google approves; that goes away once verification clears. |
| 119 | + |
| 120 | +## License |
| 121 | + |
| 122 | +MIT — see [LICENSE](LICENSE). Copyright © 2026 Unirate Team. |
0 commit comments