> ## Documentation Index
> Fetch the complete documentation index at: https://lua.nlcrack.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP

> Asynchronous HTTP requests. Requires insecure mode.

## Functions

| Function | Returns | Description |
| - | - | - |
| `http.get(url [, options], callback)` | `bool`, `error?` | GET request |
| `http.post(url, body [, options], callback)` | `bool`, `error?` | POST request |

### Options

| Field | Type | Default | Description |
| - | - | - | - |
| `headers` | `table` | `{}` | Request headers as `{["Key"] = "Value"}` |
| `timeout` | `number` | 10 | Timeout in seconds |

### Response

The callback receives a response table:

| Field | Type | Description |
| - | - | - |
| `status` | `number` | HTTP status code |
| `body` | `string` | Response body |
| `headers` | `table` | Response headers |

## Example

```lua theme={null} theme={null}
http.get('https://api.example.com/data', { timeout = 5 }, function(r)
    if r.status == 200 then
        local data = json.decode(r.body)
        print(data.result)
    end
end)

http.post('https://api.example.com/log', json.encode({ event = 'loaded' }), {
    headers = { ['Content-Type'] = 'application/json' }
}, function(r)
    print('posted:', r.status)
end)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.