cloudflare-workers-runtime-apis
Learn the core runtime APIs that power Cloudflare Workers development. This skill covers Fetch for making and handling HTTP requests, Streams for processing large payloads efficiently, Crypto for hashing and signing operations, Cache for response optimization, WebSockets for real-time connections, and text encoding utilities. Includes patterns for timeouts, retries, and error prevention.
Cloudflare Workers Runtime APIs teaches HTTP requests, streaming, cryptography, caching, WebSockets, and text encoding for Workers development.
AI-generated summary based on this skill's SKILL.md
Install
secondsky/claude-skills/cloudflare-workers-runtime-apis · repository language: TypeScript
git clone https://github.com/secondsky/claude-skills
cp -r claude-skills/plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis ~/.claude/skills/cloudflare-workers-runtime-apisnpx skillfed install secondsky/claude-skills/cloudflare-workers-runtime-apisFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to make HTTP requests in cloudflare workers?
cloudflare-workers-runtime-apis provides the Fetch API for making HTTP requests. Use the `fetch()` function to send requests and handle responses. You can set headers, configure timeouts with `AbortController`, implement retry patterns, and process response bodies as text, JSON, or streams. The Fetch API is the primary method for outbound HTTP communication in Workers.
What cryptographic operations does cloudflare-workers-runtime-apis support?
cloudflare-workers-runtime-apis includes the Crypto API for hashing, signing, and encryption. Perform HMAC signing, SHA hashing, and other cryptographic operations using the Web Crypto standard. These operations are useful for authentication, data integrity verification, and secure transformations within your Workers scripts.
How do I implement real-time features using WebSockets and Durable Objects?
cloudflare-workers-runtime-apis enables WebSocket connections paired with Durable Objects for real-time functionality. Use WebSocket hibernation to maintain persistent connections efficiently, and leverage Durable Objects as a coordination layer for state management and message broadcasting across multiple client connections.
What's the best way to process large data streams in cloudflare workers?
cloudflare-workers-runtime-apis provides the Streams API for handling large payloads efficiently. Use `ReadableStream` and `TransformStream` to process data incrementally without loading entire files into memory. Combine streaming with the Cache API to optimize response delivery and reduce bandwidth consumption.
How can I optimize response caching in cloudflare-workers-runtime-apis?
cloudflare-workers-runtime-apis includes the Cache API for response optimization. Store and retrieve cached responses using cache keys, set appropriate TTLs, and implement cache invalidation strategies. This reduces origin requests and improves performance for frequently accessed content.
What common runtime errors should I prevent in cloudflare workers?
cloudflare-workers-runtime-apis documentation covers preventing errors like "body already read" when accessing request/response bodies multiple times. Use proper error handling for fetch timeouts, AbortController signals, and stream processing failures. Implement defensive patterns to avoid runtime exceptions in production Workers.
SKILL.md
rendered from the published skill — quoted content, verbatim
Cloudflare Workers Runtime APIs
Master the Workers runtime APIs: Fetch, Streams, Crypto, Cache, WebSockets, and text encoding.
Quick Reference
| API | Purpose | Common Use |
|---|---|---|
| Fetch | HTTP requests | External APIs, proxying |
| Streams | Data streaming | Large files, real-time |
| Crypto | Cryptography | Hashing, signing, encryption |
| Cache | Response caching | Performance optimization |
| WebSockets | Real-time connections | Chat, live updates |
| Encoding | Text encoding | UTF-8, Base64 |
Quick Start: Fetch API
```typescript export default { async fetch(request: Request, env: Env): Promise<Response> { // Basic fetch const response = await fetch('https://api.example.com/data');
// With options
const postResponse = await fetch('https://api.example.com/users', {
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 11 files
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/SKILL.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/cache-api.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/crypto-api.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/encoding-api.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/fetch-api.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/streams-api.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/references/websockets.md
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/templates/crypto-operations.ts
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/templates/fetch-patterns.ts
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/templates/stream-processing.ts
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/templates/websocket-handler.ts