---
title: "Bun APIs"
description: "Overview of Bun's native APIs available on the Bun global object and built-in modules"
mode: center
---

Bun implements a set of native APIs on the `Bun` global object and through a number of built-in modules. These APIs are heavily optimized and represent the canonical "Bun-native" way to implement some common functionality.

Bun strives to implement standard Web APIs wherever possible. Bun introduces new APIs primarily for server-side tasks where no standard exists, such as file I/O and starting an HTTP server. In these cases, Bun's approach still builds atop standard APIs like `Blob`, `URL`, and `Request`.

```ts server.ts icon="/icons/typescript.svg"
Bun.serve({
  fetch(req: Request) {
    return new Response("Success!");
  },
});
```

Click the link in the right column to jump to the associated documentation.

| Topic                            | APIs                                                                                                                                                                                                                                                                                                                   |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| HTTP Server                      | [`Bun.serve`](/docs/runtime/http/server)                                                                                                                                                                                                                                                                                    |
| Shell                            | [`$`](/docs/runtime/shell)                                                                                                                                                                                                                                                                                                  |
| Bundler                          | [`Bun.build`](/docs/bundler)                                                                                                                                                                                                                                                                                                |
| File I/O                         | [`Bun.file`](/docs/runtime/file-io#reading-files-bun-file), [`Bun.write`](/docs/runtime/file-io#writing-files-bun-write), `Bun.stdin`, `Bun.stdout`, `Bun.stderr`                                                                                                                                                                |
| Child Processes                  | [`Bun.spawn`](/docs/runtime/child-process#spawn-a-process-bun-spawn), [`Bun.spawnSync`](/docs/runtime/child-process#blocking-api-bun-spawnsync)                                                                                                                                                                                  |
| TCP Sockets                      | [`Bun.listen`](/docs/runtime/networking/tcp#start-a-server-bun-listen), [`Bun.connect`](/docs/runtime/networking/tcp#start-a-server-bun-listen)                                                                                                                                                                                  |
| UDP Sockets                      | [`Bun.udpSocket`](/docs/runtime/networking/udp)                                                                                                                                                                                                                                                                             |
| WebSockets                       | `new WebSocket()` (client), [`Bun.serve`](/docs/runtime/http/websockets) (server)                                                                                                                                                                                                                                           |
| Transpiler                       | [`Bun.Transpiler`](/docs/runtime/transpiler)                                                                                                                                                                                                                                                                                |
| Routing                          | [`Bun.FileSystemRouter`](/docs/runtime/file-system-router)                                                                                                                                                                                                                                                                  |
| Streaming HTML                   | [`HTMLRewriter`](/docs/runtime/html-rewriter)                                                                                                                                                                                                                                                                               |
| Hashing                          | [`Bun.password`](/docs/runtime/hashing#bun-password), [`Bun.hash`](/docs/runtime/hashing#bun-hash), [`Bun.CryptoHasher`](/docs/runtime/hashing#bun-cryptohasher), `Bun.sha`                                                                                                                                                           |
| SQLite                           | [`bun:sqlite`](/docs/runtime/sqlite)                                                                                                                                                                                                                                                                                        |
| PostgreSQL Client                | [`Bun.SQL`](/docs/runtime/sql), `Bun.sql`                                                                                                                                                                                                                                                                                   |
| Redis (Valkey) Client            | [`Bun.RedisClient`](/docs/runtime/redis), `Bun.redis`                                                                                                                                                                                                                                                                       |
| FFI (Foreign Function Interface) | [`bun:ffi`](/docs/runtime/ffi)                                                                                                                                                                                                                                                                                              |
| DNS                              | [`Bun.dns.lookup`](/docs/runtime/networking/dns), `Bun.dns.prefetch`, `Bun.dns.getCacheStats`                                                                                                                                                                                                                               |
| Testing                          | [`bun:test`](/docs/test)                                                                                                                                                                                                                                                                                                    |
| Workers                          | [`new Worker()`](/docs/runtime/workers)                                                                                                                                                                                                                                                                                     |
| Module Loaders                   | [`Bun.plugin`](/docs/bundler/plugins)                                                                                                                                                                                                                                                                                       |
| Glob                             | [`Bun.Glob`](/docs/runtime/glob)                                                                                                                                                                                                                                                                                            |
| Cookies                          | [`Bun.Cookie`](/docs/runtime/cookies), [`Bun.CookieMap`](/docs/runtime/cookies)                                                                                                                                                                                                                                                  |
| Node-API                         | [`Node-API`](/docs/runtime/node-api)                                                                                                                                                                                                                                                                                        |
| `import.meta`                    | [`import.meta`](/docs/runtime/module-resolution#import-meta)                                                                                                                                                                                                                                                                |
| Utilities                        | [`Bun.version`](/docs/runtime/utils#bun-version), [`Bun.revision`](/docs/runtime/utils#bun-revision), [`Bun.env`](/docs/runtime/utils#bun-env), [`Bun.main`](/docs/runtime/utils#bun-main)                                                                                                                                                 |
| Sleep & Timing                   | [`Bun.sleep()`](/docs/runtime/utils#bun-sleep), [`Bun.sleepSync()`](/docs/runtime/utils#bun-sleepsync), [`Bun.nanoseconds()`](/docs/runtime/utils#bun-nanoseconds)                                                                                                                                                                    |
| Random & UUID                    | [`Bun.randomUUIDv7()`](/docs/runtime/utils#bun-randomuuidv7)                                                                                                                                                                                                                                                                |
| System & Environment             | [`Bun.which()`](/docs/runtime/utils#bun-which)                                                                                                                                                                                                                                                                              |
| Comparison & Inspection          | [`Bun.peek()`](/docs/runtime/utils#bun-peek), [`Bun.deepEquals()`](/docs/runtime/utils#bun-deepequals), `Bun.deepMatch`, [`Bun.inspect()`](/docs/runtime/utils#bun-inspect)                                                                                                                                                           |
| String & Text Processing         | [`Bun.escapeHTML()`](/docs/runtime/utils#bun-escapehtml), [`Bun.stringWidth()`](/docs/runtime/utils#bun-stringwidth), `Bun.indexOfLine`                                                                                                                                                                                          |
| URL & Path Utilities             | [`Bun.fileURLToPath()`](/docs/runtime/utils#bun-fileurltopath), [`Bun.pathToFileURL()`](/docs/runtime/utils#bun-pathtofileurl)                                                                                                                                                                                                   |
| Compression                      | [`Bun.gzipSync()`](/docs/runtime/utils#bun-gzipsync), [`Bun.gunzipSync()`](/docs/runtime/utils#bun-gunzipsync), [`Bun.deflateSync()`](/docs/runtime/utils#bun-deflatesync), [`Bun.inflateSync()`](/docs/runtime/utils#bun-inflatesync), `Bun.zstdCompressSync()`, `Bun.zstdDecompressSync()`, `Bun.zstdCompress()`, `Bun.zstdDecompress()` |
| Stream Processing                | [`Bun.readableStreamTo*()`](/docs/runtime/utils#bun-readablestreamto), `Bun.readableStreamToBytes()`, `Bun.readableStreamToBlob()`, `Bun.readableStreamToFormData()`, `Bun.readableStreamToJSON()`, `Bun.readableStreamToArray()`                                                                                           |
| Memory & Buffer Management       | `Bun.ArrayBufferSink`, `Bun.allocUnsafe`, `Bun.concatArrayBuffers`                                                                                                                                                                                                                                                     |
| Module Resolution                | [`Bun.resolveSync()`](/docs/runtime/utils#bun-resolvesync)                                                                                                                                                                                                                                                                  |
| Parsing & Formatting             | [`Bun.semver`](/docs/runtime/semver), `Bun.TOML.parse`, [`Bun.markdown`](/docs/runtime/markdown), [`Bun.color`](/docs/runtime/color)                                                                                                                                                                                                  |
| Low-level / Internals            | `Bun.mmap`, `Bun.gc`, `Bun.generateHeapSnapshot`, [`bun:jsc`](https://bun.com/reference/bun/jsc)                                                                                                                                                                                                                       |
