Skip to content

API Module Structure

The package exposes a flat WebAPI namespace. Source files are grouped by API family in lowercase directories, while ReScript module names are derived from their filenames.

  • Directorysrc
    • Directoryfetch
      • Request.res
      • Response.res
      • FetchTypes.res

Application code uses public modules such as WebAPI.Request and WebAPI.Response; it does not use the internal FetchTypes module. The supported public module list and feature bundles are described in the API surface guide.

Concrete interface modules commonly expose their value type as t; helper or operation-only modules may not have a standalone value type. Operations live on their public owner module, so an interface value can be piped into an operation:

let request = WebAPI.Request.fromURL("https://example.com")
let copiedRequest = request->WebAPI.Request.clone

Auxiliary public shapes are exposed by their owner module when consumers need to construct or name them. Internal *Types modules hold implementation details and are not stable public targets. Prefer public aliases or inferred types; do not add internal modules to the API just to make an internal reference visible.

Web APIs often inherit interface members. Bindings expose the operations needed by public interface modules and use explicit conversion helpers where the source API can safely be viewed as a broader interface. Runtime narrowing belongs in the destination type’s checked classify helper, rather than an unchecked cast in consumer code. See the API surface guide’s DOM section for an example.