API Reference
DynamicIsland.http
Network fetch API for extensions. Requires the "network" permission.
DynamicIsland.http
HTTP client for extensions. Requires "network" in your manifest's permissions array.
http.fetch(url, options?)
Returns a Promise that resolves with the response.
const res = await DynamicIsland.http.fetch("https://api.example.com/data");Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Request URL |
options.method | string | HTTP method. Default: "GET" |
options.headers | object | Request headers |
options.body | string | Request body (for POST/PUT) |
options.timeout | number | Timeout in seconds. Default: 10 |
Response
{
status: number, // HTTP status code
data: unknown, // Parsed JSON (if Content-Type is application/json)
text: string, // Raw response text
error?: string, // Error message (network error, timeout, etc.)
}Examples
GET JSON
async function getWeather(city) {
const res = await DynamicIsland.http.fetch(
`https://wttr.in/${encodeURIComponent(city)}?format=j1`
);
if (res.status !== 200 || res.error) {
console.error("Weather fetch failed:", res.error);
return null;
}
return res.data.current_condition[0];
}POST with headers
async function postData(endpoint, payload) {
const res = await DynamicIsland.http.fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${DynamicIsland.settings.get("apiKey")}`,
},
body: JSON.stringify(payload),
timeout: 5,
});
return res.data;
}Polling with setInterval
let status = "unknown";
async function poll() {
const res = await DynamicIsland.http.fetch("https://status.example.com/api");
status = res.data?.status ?? "unknown";
}
poll();
setInterval(poll, 30000);
DynamicIsland.registerModule({
compact() {
const color = status === "ok" ? "#22c55e" : "#ef4444";
return View.hstack([
View.icon("circle.fill", { size: 8, color }),
View.text(status, { style: "caption" }),
]);
},
});Rate limiting
Be a good citizen. Avoid polling more frequently than your data actually changes. Use refreshInterval for display updates, but network calls should happen less often (use setInterval to separate concerns).