xtract.bot
POST /api/url-encode

URL-encode arbitrary text. Two modes: `component` (escapes `?&=#`, suitable for query values) and `path` (preserves `/`, suitable for path segments).

Percent-encodes a string so it is safe to use in a URL. Two modes: - `component` (default, equivalent to JavaScript `encodeURIComponent`): escapes everything that has special meaning in a URL — `?`, `&`, `=`, `#`, etc. Use this for query parameter values. - `path` (equivalent to `encodeURI`): preserves `/`, `:`, `?`, `&`, `=` so they keep their URL-meaning. Use this for whole URLs or path segments.

Inputs

NameTypeDefaultDescription
input*stringText to encode.
scopeenum (component | uri | form)"component"Encoding scope: `component` (encodeURIComponent), `uri` (encodeURI), or `form` (application/x-www-form-urlencoded).

Response

Modes: json, text. Cache: yes (24h TTL).

Code samples

Built from the search example.


curl -X POST https://api.xtract.bot/api/url-encode \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "input": "hello world & foo=bar",
  "scope": "component"
}'