Skip to content

$(queryescape)

Syntax
$(queryescape <text>)
Arguments
Required

The $(queryescape) variable is used to encode a string for safe use in URLs. It replaces spaces with plus signs and escapes special characters, making it ideal for creating dynamic search queries or links within chatbot commands.

!command add !google Let me Google that for you: https://google.com/search?q=$(queryescape ${1:})
Example chat
ViewerName:!google StreamElements chatbot
partner badgemoderator badgeStreamElements:Let me Google that for you: https://google.com/search?q=StreamElements+chatbot

To use the $(queryescape) variable, include it in your command with the text you want to encode as its parameter:

$(queryescape <text>)

Replace <text> with the string you want to encode for URL usage.

A YouTube search command:

!command add !yt https://www.youtube.com/results?search_query=$(queryescape ${1:})
Example chat
ViewerName:!yt funny cat videos
partner badgemoderator badgeStreamElements:https://www.youtube.com/results?search_query=funny+cat+videos

The $(queryescape) variable takes a single parameter:

  • text: The string you want to encode for URL usage. This can be static text or a dynamic value from another variable or user input.

If no text is provided, the variable is not replaced and appears as literal text in the response.

$(queryencode) can also be used as an alias for $(queryescape).

  • $(pathescape): Escapes text for use in URL paths (encodes spaces as %20).
  • $(customapi): Used to fetch content from a URL, often combined with $(queryescape) for dynamic web requests.
  • Argument tokens: Represent user input in custom commands, frequently used with $(queryescape) to create dynamic queries.

Q: Why should I use $(queryescape) instead of just inserting text directly into a URL?

A: Using $(queryescape) ensures that special characters and spaces are properly encoded, preventing errors in the URL and ensuring it works correctly across different platforms and browsers.

Q: What’s the difference between $(queryescape) and $(pathescape)?

A: $(queryescape) is for query parameters (everything after ?) and encodes spaces as +. $(pathescape) is for the path portion of a URL and encodes spaces as %20.

Q: Can I use $(queryescape) with other variables or in more complex commands?

A: Yes, you can combine $(queryescape) with other variables and use it in complex commands. It’s especially useful when working with user input or dynamic data that needs to be included in URLs.