fetch() calls — but understanding where those calls live and how to handle API keys gives you full control over the result.
Extensy handles client-side API calls only. There is no server-side backend — all requests originate from the user’s browser.
Choose where to make the API call
Place yourfetch() call in the right file depending on what triggers it:
Call an API from a content script
Use this pattern when the request is triggered by something the user does on a page:Call an API from the background service worker
Use this pattern for cross-origin requests or calls that run independently of any tab:Store API keys securely
Never hardcode sensitive API keys into your extension if you plan to distribute it — anyone can unpack a.crx file and read them.
- Options page (recommended)
- Hardcoded (personal use only)
Let users enter their own API key and save it with Then read it wherever you make the fetch call:
chrome.storage.local:Prompt Extensy to add an API call
When generating your extension, describe the API call in your prompt:
“When the user clicks the toolbar icon, fetch the current Bitcoin price from https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd and display it in the popup.”
Extensy will generate the fetch() call in the appropriate file and wire up the response to the UI. If the API requires a key, specify where you want it stored:
“Store the API key in chrome.storage.local and let users enter it on the options page.”
Handle errors gracefully
Always checkresponse.ok and handle network failures: