workers generated API reference
workers
__all__ = ('Blob', 'BlobEnding', 'BlobValue', 'Body', 'Context', 'DurableObject', 'FetchKwargs', 'FetchResponse', 'File', 'FormData', 'FormDataValue', 'Headers', 'JSBody', 'Request', 'RequestInitCfProperties', 'Response', 'WorkerEntrypoint', 'WorkflowEntrypoint', 'env', 'fetch', 'handler', 'import_from_javascript', 'patch_env', 'python_from_rpc', 'python_to_rpc', 'waitUntil', 'wait_until')
module-attribute
BlobValue = str | bytes | js.ArrayBuffer | js.TypedArray | js.DataView | js.Blob | Blob | File
FormDataValue = str | js.Blob | Blob
Body = str | bytes | FormData | Blob | JSBody | None
Headers = dict[str, str] | list[tuple[str, str]] | js.Headers
JSBody = js.Blob | JsBuffer | js.FormData | js.ReadableStream | js.URLSearchParams
Blob
size
property
content_type
property
js_object
property
__init__(blob_parts, content_type=None, endings=None)
text()
async
bytes()
async
slice(start=None, end=None, content_type=None)
BlobEnding
Bases: StrEnum
TRANSPARENT = 'transparent'
class-attribute
instance-attribute
NATIVE = 'native'
class-attribute
instance-attribute
File
Bases: Blob
name
property
last_modified
property
__init__(blob_parts, filename=None, content_type=None, endings=None, last_modified=None)
DurableObject
Bases: _Typed[EnvT], _Entrypoint
ctx
instance-attribute
WorkerEntrypoint
Bases: _Typed[EnvT], _Entrypoint
ctx
instance-attribute
WorkflowEntrypoint
Bases: _Typed[EnvT], _Entrypoint
__init_subclass__(**kwargs)
FormData
Bases: MutableMapping[str, Any]
Key/value pairs for forms, following multidict and the JS FormData API.
js_object
property
__init__(form_data=None)
__getitem__(key)
__setitem__(key, value)
__delitem__(key)
__contains__(key)
__iter__()
__len__()
append(key, value, filename=None)
delete(key)
keys()
values()
items()
get_all(key)
Request
Bases: BodyMixin
js_object
property
body
property
body_used
property
cf
property
Cloudflare's properties of an incoming request, or None if absent.
cache
property
credentials
property
destination
property
integrity
property
is_history_navigation
property
keepalive
property
method
property
mode
property
redirect
property
referrer
property
referrer_policy
property
url
property
__init__(input, **options)
__repr__()
buffer()
async
bytes()
async
clone()
json(**kwargs)
async
text()
async
FetchResponse
Bases: BodyMixin, FetchResponse
body
property
js_object
property
json = _Json()
class-attribute
instance-attribute
formData()
async
replace_body(body)
A new Response with this one's status and headers and a new body.
redirect(url, status=HTTPStatus.FOUND)
staticmethod
from_json(data, status=HTTPStatus.OK, status_text='', headers=None)
staticmethod
Response
Bases: FetchResponse
An HTTP response, with an API like the web's Response.
__init__(body=None, status=None, status_text='', headers=None, web_socket=None)
__repr__()
Context
Bases: Protocol
waitUntil(other)
FetchKwargs
Bases: TypedDict
https://developers.cloudflare.com/workers/runtime-apis/request/#options
headers
instance-attribute
body
instance-attribute
method
instance-attribute
redirect
instance-attribute
cf
instance-attribute
fetcher
instance-attribute
RequestInitCfProperties
Bases: TypedDict
https://developers.cloudflare.com/workers/runtime-apis/request/#the-cf-property-requestinitcfproperties
apps
instance-attribute
cacheEverything
instance-attribute
cacheKey
instance-attribute
cacheTags
instance-attribute
cacheTtl
instance-attribute
cacheTtlByStatus
instance-attribute
image
instance-attribute
mirage
instance-attribute
polish
instance-attribute
resolveOverride
instance-attribute
scrapeShield
instance-attribute
webp
instance-attribute
handler(func)
For a module-level handler such as on_fetch, which workerd calls only
on dates before 2025-08-14: converts a JS Request argument to a Request
and wraps the env, as in the stock SDK.
python_from_rpc(obj)
Convert a value workerd received over RPC to Python, as the stock SDK does.
python_to_rpc(value)
Convert a Python value to send over RPC, as the stock SDK does.
import_from_javascript(module_name)
Import a JS module, such as "cloudflare:sockets", from Python.
"cloudflare:workers" and "cloudflare:sockets" are imported ahead of time, so they work everywhere. Any other module goes through run_sync, which Python 3.12 Workers lack. On 3.13 and 3.14 it works at top level too.
patch_env(*args, **kwargs)
Removed from workerd. The stock SDK still exports it, so crosswind does.