# StormFetch Complete Functions List

Version `1.16.3` · Public API inventory for npm users.

> **Official package signature**  
> Built by **Pradeep Kumar Sheoran (Stack Developer)** at **BSG Technologies**  
> WhatsApp: **+91-8595147850** · [Visit BSG Technologies — meet, learn, contribute, discuss, or accept a coffee invitation](https://bsgtechnologies.com)

[Client setup](#client-setup) · [HTTP calls](#http-calls) · [API helpers](#api-and-body-helpers) · [Cache](#cache-and-debugging) · [Streams](#streams-and-live-data) · [Offline/mobile](#offline-mobile-and-plugins) · [React](#react-hooks) · [DOM](#dom-and-scraping) · [Testing](#testing-and-adapters) · [Security](#security-and-observability) · [Runtime](#runtime-and-url-utilities)

Use this file as the quick function directory. For beginner lessons with parameters, returns, examples, output, errors, and use cases, open [LEARN_HERE.md](./LEARN_HERE.md). For configuration details, open [API_REFERENCE.md](./API_REFERENCE.md).

## Client setup

| Public API | What it is used for | Returns |
| --- | --- | --- |
| `fastApi` | Ready-made starter client for quick experiments | `FastApiClient` |
| `new FastApiClient(options)` | Direct class construction | `FastApiClient` instance |
| `createStormFetchClient(options?)` | Recommended reusable browser, Node, or shared client | `FastApiClient` |
| `createFastApiClient(options?)` | Backward-compatible alias | `FastApiClient` |
| `createTypedStormFetchClient<TEndpoints>(options?)` | Compile-time endpoint map typing | `TypedStormFetchClient<TEndpoints>` |
| `createReactNativeStormFetchClient(options?)` | React Native/Expo-safe client and injected native services | `FastApiClient` |
| `createStormFetchServerClient(options?)` | SSR/backend client with forwarded cookies and headers | `FastApiClient` |
| `STORMFETCH_PACKAGE_INFO` | Official version, developer, company, contact, website, and code signature | Frozen metadata object |
| `STORMFETCH_ERROR_CODES` | Stable error-code names for application branching | Frozen error-code map |

## HTTP calls

| Client function | Job | Typical use |
| --- | --- | --- |
| `request(config)` | Full low-level request | Dynamic method or advanced config |
| `fetch(url, config?)` | Fetch-like StormFetch call | Migration from native Fetch |
| `get(url, config?)` / `GET(...)` | Read a resource | Lists and details |
| `post(url, data?, config?)` / `POST(...)` | Create or trigger | Forms, login, commands |
| `put(url, data?, config?)` / `PUT(...)` | Replace a resource | Full record update |
| `patch(url, data?, config?)` / `PATCH(...)` | Partially update | Edit changed fields |
| `delete(url, config?)` / `DELETE(...)` | Delete a resource | Remove/archive |
| `head(url, config?)` / `HEAD(...)` | Read headers without a body | Existence, size, ETag |
| `options(url, config?)` / `OPTIONS(...)` | Read server capabilities | CORS and allowed methods |
| `query(url, data?, config?)` / `QUERY(...)` | Send an HTTP QUERY request | Structured safe query body |

All request functions resolve to `FastApiResponse`, containing `data`, `status`, `statusText`, `headers`, `config`, `requestId`, and `duration`. They reject with a normalized `StormFetchError`.

## API and body helpers

| Function | What it simplifies | Returns |
| --- | --- | --- |
| `postJson(url, data?, config?)` | Explicit JSON POST | Response promise |
| `postForm(url, data, config?)` | URL-encoded form POST | Response promise |
| `postMultipart(url, data, config?)` | File/multipart POST | Response promise |
| `graphql(query, variables?, config?)` | GraphQL request body | Response promise |
| `batch(requests)` | Multiple parallel calls | Ordered response array |
| `poll(url, options)` | Repeated GET until stopped | Poll controller |
| `resource(basePath)` | REST CRUD helper set | `list`, `detail`, `create`, `replace`, `update`, `remove` |
| `contract(definition)` | Named typed endpoint functions | Contract function object |
| `createFormData(data)` / `client.createFormData(data)` | Browser/Node multipart body | `FormData` |
| `createReactNativeFile(uri, name, type)` | Mobile file descriptor | `ReactNativeFile` |
| `isReactNativeFile(value)` | Validate a mobile descriptor | Boolean type guard |
| `download(url, fileName?, config?)` | Fetch and optionally save a file | `FastApiResponse<Blob>` |
| `saveBlob(blob, fileName?)` | Save an existing browser Blob | `void` |
| `generateStormFetchServicesFromOpenApi(document, options?)` | Generate deterministic TypeScript service code | Source-code string |

## Cache and debugging

| Function/property | Job | Returns |
| --- | --- | --- |
| `clearCache(key?)` | Clear memory cache immediately | `void` |
| `clearCacheAsync(key?)` | Clear sync/async cache storage | `Promise<void>` |
| `invalidateTags(tags)` | Remove related cached records | `Promise<void>` |
| `prefetch(url, config?)` | Load and cache before UI needs data | Response promise |
| `dehydrateCache()` | Export cache for SSR/persistence | Cache snapshot |
| `hydrateCache(snapshot)` | Restore exported cache | `Promise<void>` |
| `cacheKeys()` | Inspect stored cache keys | `string[]` |
| `cacheManager` | Small cache facade | `prefetch`, `invalidate`, `clear`, `keys`, `dehydrate`, `hydrate`, `subscribe` |
| `history()` | Read redacted request history | History entries |
| `clearHistory()` | Remove request history | `void` |
| `replay(requestId)` | Repeat a recorded request | Response promise |
| `toCurl(requestIdOrConfig)` | Create redacted curl command | `string` |
| `toHAR()` | Export redacted HAR 1.2 data | HAR object |
| `subscribe(listener)` | Observe lifecycle/security/cache events | Unsubscribe function |
| `policy(match, config)` | Apply config to matching routes | Remove-policy function |
| `createStormFetchDevTools(client, options?)` | Headless history/cache/offline inspector | DevTools controller |
| `mountStormFetchDevTools(client, element, options?)` | Mount dependency-free browser inspector | Controller with `unmount()` |

## Streams and live data

| Function | Best for | Returns |
| --- | --- | --- |
| `streamText(url, config?)` | Text chunks | `AsyncIterable<string>` |
| `streamJson(url, config?)` | One streamed JSON document | Parsed value promise |
| `streamNdjson(url, config?)` | One JSON object per line | `AsyncIterable<T>` |
| `sse(url, options?)` | Server-Sent Events | Controller with `close()` |

## Offline, mobile, and plugins

| Function | Job | Returns |
| --- | --- | --- |
| `flushOfflineQueue()` | Send queued mutations now | `Promise<void>` |
| `offlineQueueSnapshot()` | Inspect pending/dead-letter work | Queue snapshot |
| `retryOfflineRequest(id)` | Retry one queued/dead request | `Promise<void>` |
| `discardOfflineRequest(id)` | Permanently discard one request | `Promise<void>` |
| `retryOfflineBatch(ids?)` | Retry selected/all dead letters | `Promise<void>` |
| `reconcileOfflineRequest(id, config)` | Replace conflicted request data then retry | `Promise<void>` |
| `createMemoryOfflineQueueStorage(initial?)` | In-memory queue persistence adapter | Storage adapter |
| `createJsonOfflineQueueStorage(storage, options?)` | JSON/encrypted app-storage adapter | Storage adapter |
| `nativeUpload(options)` | Native/background upload | Transfer result promise |
| `nativeDownload(options)` | Native/background download | Transfer result promise |
| `startNativeUpload(options)` | Pausable upload task | Native transfer task |
| `startNativeDownload(options)` | Pausable download task | Native transfer task |
| `usePlugin(plugin)` | Install a verified plugin | Async uninstall function |
| `removePlugin(name)` | Remove plugin by name | `Promise<void>` |
| `installedPlugins()` | Inspect installed plugins | Plugin metadata array |
| `dispose()` | Remove listeners/plugins and release resources | `Promise<void>` |
| `authPlugin(getToken)` | Attach live bearer token | Plugin |
| `languagePlugin(getLanguage)` | Attach language header | Plugin |
| `loggerPlugin(logger?)` | Request/response logging | Plugin |
| `hmacSigningPlugin(options)` | Sign outgoing requests | Security plugin |
| `secureLoggerPlugin(options?)` | Log only redacted metadata | Security plugin |
| `securityRateLimitPlugin(options?)` | Detect repeated security/auth responses | Security plugin |

## React hooks

Call `createStormFetchHooks(React, client)` once. It returns:

| Hook | Job | Main result |
| --- | --- | --- |
| `useStormQuery(url, config?, options?)` | Automatic GET on mount | `data`, `error`, `loading`, `refetch`, `reset` |
| `useLazyStormQuery(url, config?, options?)` | GET only when requested | Query state with `refetch` |
| `useStormMutation(url, method?, options?)` | POST/PUT/PATCH/DELETE UI state | `mutate`, `data`, `error`, `loading`, `reset` |
| `useStormInfiniteQuery(url, options)` | Page/cursor loading | `pages`, `fetchNextPage`, `hasNextPage`, states |

## DOM and scraping

| Function | Job | Returns |
| --- | --- | --- |
| `getHtml(url, config?)` | Fetch HTML text | String response |
| `getXml(url, config?)` | Fetch XML text | String response |
| `getDom(url, config?)` | Fetch and parse document | DOM response |
| `parseDom(html, mimeType?)` | Parse existing markup | Document adapter |
| `scrape(url, schema, config?)` | Fetch and extract typed fields | Typed scrape response |
| `scrapeDocument(document, schema)` | Extract fields from existing document | Typed object |
| `selectText(document, selector)` | Read first matched text | `string | undefined` |
| `selectAttr(document, selector, attr)` | Read first matched attribute | `string | undefined` |
| `selectAll(document, selector, mapper)` | Map every match | Array |
| `extractMeta(document)` | Extract meta tags | Record |
| `extractLinks(document)` | Extract links | `string[]` |
| `extractImages(document)` | Extract image sources | `string[]` |
| `extractJsonLd(document)` | Parse JSON-LD scripts | `unknown[]` |

## Testing and adapters

| API | Job | Use directly when |
| --- | --- | --- |
| `createMockAdapter(options?)` | Deterministic mocked responses | Unit testing a client |
| `createMockServer(options?)` | Routes, scenarios, request history | Demos and complex tests |
| `createStormFetchError(input)` | Build normalized errors | Custom transports/tests |
| `createFastApiError(input)` | Compatibility alias | Older application code |
| `isStormFetchError(error)` | Safe error narrowing | Inside `catch` |
| `createInterceptorManager<T>()` | Standalone interceptor registry | Custom integrations |
| `dispatchAdapter(config)` | Automatic adapter selection | Custom client internals |
| `fetchAdapter(config)` | Fetch transport | Browser/RN/Deno/Bun override |
| `xhrAdapter(config)` | Browser XHR transport | Progress events |
| `httpAdapter(config)` | Node HTTP/1.1 transport | Streams/proxy/TLS |
| `http2Adapter(config)` | Node HTTP/2 transport | HTTP/2 server |
| `new StormFetchCache(storage?)` | Direct cache engine | Custom cache orchestration |
| `FastApiCache` | Cache class alias | Compatibility |
| `new RequestDedupe()` | Share in-flight promise by key | Custom dedupe layer |
| `new RequestQueue()` | Concurrency/priority scheduling | Custom scheduler |

## Security and observability

| Function | Job | Returns |
| --- | --- | --- |
| `createOpenTelemetryObservability(options)` | Bridge any compatible tracer | Client observability config |
| `createStormFetchMetrics()` | Count requests, retries, hits, failures, duration | `onEvent`, `snapshot`, `reset` |
| `STORMFETCH_ERROR_CODES` | Compare errors without magic strings | Frozen constants |

Security controls such as allowed hosts/CIDRs, HTTPS enforcement, DNS checks, cloud-metadata blocking, XSRF, redirect policy, payload limits, TLS/mTLS, certificate pins, sensitive-data redaction, and credential forwarding are configured through `createStormFetchClient({ security, ... })`.

## Runtime and URL utilities

| Function | Job | Returns |
| --- | --- | --- |
| `isBrowser()` | Detect DOM browser | Boolean |
| `isReactNative()` | Detect classic/new React Native | Boolean |
| `isNodeLike()` | Detect Node but exclude browser/RN | Boolean |
| `isDeno()` | Detect Deno | Boolean |
| `isBun()` | Detect Bun | Boolean |
| `getRuntimeInfo()` | Full runtime/capability support report | Serializable info object |
| `buildQueryString(params?, serializer?)` | Build encoded URL query | String beginning with `?` or empty |
| `replacePathParams(url, pathParams?)` | Replace `:id` placeholders | URL string |
| `joinURL(baseURL, url)` | Safely combine URL parts | URL string |

---

**Package signature:** `STORMFETCH_PACKAGE_INFO.signature`  
**Official support:** [https://bsgtechnologies.com](https://bsgtechnologies.com) · **+91-8595147850 (Also WhatsApp)**
