---
title: HTTP
slug: aura/http
docTags: 
createdAt: 2025-07-07T20:39:55.891Z
---

Utilizada para fazer requisições utilizando o protocolo HTTP.

## Atalhos

- **[Get](docId:9-nY7HWqvhaOsJFQ9z_93)**
- **[Post](docId:9-nY7HWqvhaOsJFQ9z_93)**
- **[Put](docId:9-nY7HWqvhaOsJFQ9z_93)**
- **[Delete](docId:9-nY7HWqvhaOsJFQ9z_93)**
- **[Patch](docId:9-nY7HWqvhaOsJFQ9z_93)**

***

### Métodos

### GET

```lua
-- @param url String containing the url.
-- @param @optional headers Table containing the headers of the request.
-- @param @optional body String containing the JSON encoded body.
-- @return a table containing headers, status, text. 
http.get(url, headers, body)
```

```lua
-- example usage:

local request = http.get("https://httpbin.org/get")

local body = request.text
local headers = request.headers
local status = request.status

--[[
request value:

{
  headers = {
    ["access-control-allow-credentials"] = "true",
    ["access-control-allow-origin"] = "*",
    connection = "keep-alive",
    ["content-length"] = "222",
    ["content-type"] = "application/json",
    date = "Fri, 27 Dec 2024 20:55:39 GMT",
    server = "gunicorn/19.9.0"
  },
  status = 200,
  text = '{\n  "args": {}, \n  "headers": {\n    "Accept": "*/*", \n    "Host": "httpbin.org", \n    "X-Amzn-Trace-Id": "Root=1-676f1449-635d770f2b8b549173c3fa96"\n  }, \n  "origin": "186.235.83.146", \n  "url": "https://httpbin.org/get"\n}\n'
}

--]]
```

### POST

```lua
-- @param url String containing the url.
-- @param @optional headers Table containing the headers of the request.
-- @param @optional body String containing the JSON encoded body.
-- @return a table containing headers, status, text. 
http.post(url, headers, body)
```

```lua
-- example usage:

local request = http.post(
    "https://httpbin.org/post",
    { ["Content-Type"] = "application/json" },
    json.encode({key = "value"})
)

local body = request.text
local headers = request.headers
local status = request.status
```

### PUT

```lua
-- @param url String containing the url.
-- @param @optional headers Table containing the headers of the request.
-- @param @optional body String containing the JSON encoded body.
-- @return a table containing headers, status, text. 
http.put(url, headers, body)

```

```lua
-- example usage:

local request = http.put(
    "https://httpbin.org/put",
    { ["Content-Type"] = "application/json" },
    nil
)

local body = request.text
local headers = request.headers
local status = request.status
```

### DELETE

```lua
-- @param url String containing the url.
-- @param @optional headers Table containing the headers of the request.
-- @param @optional body String containing the JSON encoded body.
-- @return a table containing headers, status, text. 
http.delete(url, headers, body)
```

```lua
-- example usage:

local request = http.delete(
    "https://httpbin.org/delete",
    { ["Content-Type"] = "application/json" },
    nil
)

local body = request.text
local headers = request.headers
local status = request.status
```

### PATCH

```lua
-- @param url String containing the url.
-- @param @optional headers Table containing the headers of the request.
-- @param @optional body String containing the JSON encoded body.
-- @return a table containing headers, status, text. 
http.patch(url, headers, body)
```

```lua
-- example usage:

local request = http.patch("https://httpbin.org/patch")

local body = request.text
local headers = request.headers
local status = request.status
```

