# HttpService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/HttpService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/HttpService

Allows sending HTTP requests and provides various web-related and JSON methods.

## Properties

### HttpEnabled

```luau
HttpService.HttpEnabled: boolean = false
```

- Tags: Write: Local user security, Read capabilities: Network

Indicates whether HTTP requests can be sent to external websites.

## Methods

### CreateWebStreamClient

```luau
HttpService:CreateWebStreamClient(streamClientType: Enum.WebStreamClientType, requestOptions: { [string]: any }): WebStreamClient
```

- Tags: Capabilities: Network

Creates a client that opens a persistent connection to stream data.

Parameters:

- `streamClientType`: The type of streaming connection to intiialize the client with.
- `requestOptions`: A dictionary containing information to be requested from the server. It is identical to `requestOptions` in [`HttpService:RequestAsync()`](https://rapi.sleaze.dev/classes/HttpService.md).

Returns: A stateful client that emits events in the stream lifecycle.

### CreateWebStreamClientInternal

```luau
HttpService:CreateWebStreamClientInternal(streamClientType: Enum.WebStreamClientType, requestOptions: { [string]: any }): WebStreamClient
```

- Tags: Roblox script security

### GenerateGUID

```luau
HttpService:GenerateGUID(wrapInCurlyBraces: boolean? = true): string
```

- Tags: Thread safe

Generates a UUID/GUID random string, optionally with curly braces.

Parameters:

- `wrapInCurlyBraces`: Whether the returned string should be wrapped in curly braces (`{}`).

Returns: The randomly generated UUID.

### GetAsync

```luau
HttpService:GetAsync(url: any, nocache: boolean? = false, headers: any): string
```

- Tags: Yields, Capabilities: Network

Sends an HTTP `GET` request.

Parameters:

- `url`: The web address you are requesting data from.
- `nocache`: Whether the request stores (caches) the response.
- `headers`: Used to specify some HTTP request headers.

Returns: The GET request's response body.

### GetHttpEnabled

```luau
HttpService:GetHttpEnabled(): boolean
```

- Tags: Roblox script security

### GetSecret

```luau
HttpService:GetSecret(key: string): Secret
```

- Tags: Thread safe, Capabilities: Network

Returns a [`Secret`](https://rapi.sleaze.dev/index/types/Secret.md) from the secrets store.

Parameters:

- `key`: The name of the secret to fetch, matching the identifier under which it was added to the experience's secrets store.

Returns: A [`Secret`](https://rapi.sleaze.dev/index/types/Secret.md) wrapping the stored value associated with `key`.

### GetUserAgent

```luau
HttpService:GetUserAgent(): string
```

- Tags: Roblox script security

### JSONDecode

```luau
HttpService:JSONDecode(input: string): any
```

- Tags: Custom Lua state, Thread safe

Decodes a JSON string into a Luau table.

Parameters:

- `input`: The JSON object being decoded.

Returns: The decoded JSON object as a Luau table.

### JSONDecodeAsync

```luau
HttpService:JSONDecodeAsync(input: string): any
```

- Tags: Yields, Roblox script security

### JSONEncode

```luau
HttpService:JSONEncode(input: any): string
```

- Tags: Custom Lua state, Thread safe

Generate a JSON string from a Luau table.

Parameters:

- `input`: The input Luau table.

Returns: The returned JSON string.

### JSONEncodeAsync

```luau
HttpService:JSONEncodeAsync(obj: any): string
```

- Tags: Yields, Roblox script security

### PostAsync

```luau
HttpService:PostAsync(url: any, data: string, content_type: Enum.HttpContentType? = Enum.HttpContentType.ApplicationJson, compress: boolean? = false, headers: any): string
```

- Tags: Yields, Capabilities: Network

Sends an HTTP `POST` request.

Parameters:

- `url`: The destination address for the data.
- `data`: The data being sent.
- `content_type`: Modifies the value in the `Content-Type` header sent with the request.
- `compress`: Determines whether the data is compressed (**gzipped**) when sent.
- `headers`: Used to specify some HTTP request headers.

Returns: The HTTP response sent back indicating the request result.

### RequestAccessTokenScopesAsync

```luau
HttpService:RequestAccessTokenScopesAsync(requiredScopes: { any }): Secret
```

- Tags: Yields, Local user security

### RequestAsync

```luau
HttpService:RequestAsync(requestOptions: { [string]: any }): { [string]: any }
```

- Tags: Yields, Capabilities: Network

Sends an HTTP request using any HTTP method given a dictionary of information.

Parameters:

- `requestOptions`: A dictionary containing information to be requested from the server specified.

Returns: A dictionary containing response information from the server specified.

### RequestInternal

```luau
HttpService:RequestInternal(options: { [string]: any }): Instance
```

- Tags: Roblox script security

### SetHttpEnabled

```luau
HttpService:SetHttpEnabled(enabled: boolean)
```

- Tags: Roblox script security

### UrlEncode

```luau
HttpService:UrlEncode(input: string): string
```

- Tags: Thread safe, Capabilities: Network

Replaces URL-unsafe characters with '%' and two hexadecimal characters.

Parameters:

- `input`: The string (URL) to encode.

Returns: The encoded string.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
