---
title: "Http"
sidebar_label: "Http"
description: "Kotlin binding reference: Http."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Http](index.md)

# Http

[common]\
object [Http](index.md)

The runtime's HTTP client: text and byte downloads, a download to a file (resumable), the full response of a GET, a POST or a DELETE, and the streaming reads whose chunks or events arrive through a sink on the calling thread. A failure to complete a request is a [ClikaRtException](../ClikaRtException/index.md); an answered status is data in the [HttpResponse](../HttpResponse/index.md).

```kotlin
val page = Http.getText("https://example.com/")
val reply = Http.post("https://api.example.com/v1/chat", """{"prompt": "hi"}""")
if (reply.isOk) println(reply.text())
```

## Functions

| Name | Summary |
|---|---|
| [delete](delete.md) | [common]<br>fun [delete](delete.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [HttpResponse](../HttpResponse/index.md)<br>DELETE [url](delete.md) and answer the full response. |
| [downloadBytes](downloadBytes.md) | [common]<br>fun [downloadBytes](downloadBytes.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)<br>GET [url](downloadBytes.md) and answer its body bytes. |
| [downloadFile](downloadFile.md) | [common]<br>fun [downloadFile](downloadFile.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), destPath: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>Download [url](downloadFile.md) to [destPath](downloadFile.md) and answer the path written; a partial file resumes when [DownloadOptions.resume](../DownloadOptions/resume.md) is set. |
| [fetch](fetch.md) | [common]<br>fun [fetch](fetch.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [HttpResponse](../HttpResponse/index.md)<br>GET [url](fetch.md) and answer the full response, any status as data. |
| [fetchFile](fetchFile.md) | [common]<br>fun [fetchFile](fetchFile.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), destPath: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [HttpResponse](../HttpResponse/index.md)<br>GET [url](fetchFile.md) into [destPath](fetchFile.md) and answer the response facts (its body streamed to the file). |
| [getSse](getSse.md) | [common]<br>fun [getSse](getSse.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), sink: [SseSink](../SseSink/index.md), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS)<br>GET [url](getSse.md) as a Server-Sent-Events stream, each event to [sink](getSse.md). |
| [getStream](getStream.md) | [common]<br>fun [getStream](getStream.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), sink: [ChunkSink](../ChunkSink/index.md), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS)<br>GET [url](getStream.md) and hand each body chunk to [sink](getStream.md) as it arrives; a sink that throws stops the transfer with `CANCELLED`. |
| [getText](getText.md) | [common]<br>fun [getText](getText.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>GET [url](getText.md) and answer its body as text. |
| [post](post.md) | [common]<br>fun [post](post.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) = &quot;application/json&quot;, options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [HttpResponse](../HttpResponse/index.md)<br>POST [body](post.md) to [url](post.md) and answer the full response. |
| [postSse](postSse.md) | [common]<br>fun [postSse](postSse.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), sink: [SseSink](../SseSink/index.md), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS)<br>POST [body](postSse.md) to [url](postSse.md) and read the answer as a Server-Sent-Events stream, each event to [sink](postSse.md). |
| [postStream](postStream.md) | [common]<br>fun [postStream](postStream.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), sink: [ChunkSink](../ChunkSink/index.md), options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS)<br>POST [body](postStream.md) to [url](postStream.md) and hand each response chunk to [sink](postStream.md). |
| [postText](postText.md) | [common]<br>fun [postText](postText.md)(url: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) = &quot;application/json&quot;, options: [DownloadOptions](../DownloadOptions/index.md) = DEFAULTS): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>POST [body](postText.md) to [url](postText.md) with [contentType](postText.md) and answer the response body as text. |