Skip to content

URL Encode API

Overview

The URL Encode API percent-encodes text and returns the encoded result in a text file, along with a preview. Requests use the synchronous body mode.

Endpoint

Method Path URL
POST /url-encode-api https://api.apidatatools.com/url-encode-api

Authentication

Include your API key in the x-api-key header.

Input modes

Mode Behavior
body Send raw text in the request body. The request is processed synchronously.

Headers

Header names are case-insensitive. The spellings below are the documented lowercase forms.

Header Type Required Default / values Description
x-api-key String Yes Your API key Authenticates the request.
x-source-type String No Defaults to body; supported documented mode: body Selects the input source.
x-url-safe String No Empty string Characters to leave unencoded.

Request body

Send non-empty raw text as the request body. Do not wrap the text in JSON.

The x-url-safe header can specify characters to leave unencoded. For example, setting it to / leaves slashes unencoded.

curl examples

Encode raw text:

curl -X POST 'https://api.apidatatools.com/url-encode-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: body' \
  --data-raw 'hello world?'

Leave / unencoded:

curl -X POST 'https://api.apidatatools.com/url-encode-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: body' \
  -H 'x-url-safe: /' \
  --data-raw 'a/b c'

Success responses

A successful request returns HTTP 200 with a JSON response containing:

Field Description
request_id Identifier for the request.
status success when processing completes.
file Temporary download URL for the encoded .txt file.
preview A text preview of the encoded output.

Download URLs are temporary; availability and retention depend on your plan.

Error handling

Errors use an envelope containing status, error, request_id, and details.message. Additional fields may appear in details.

HTTP status Error code Meaning
400 INVALID_SOURCE_TYPE The source type is invalid.
400 INVALID_BODY_ENCODING The request body could not be decoded.
400 EMPTY_BODY The request body is empty.
400 INVALID_TEXT The input is not valid non-empty text.
400 URL_ENCODE_ERROR The text could not be URL-encoded.
401 UNAUTHORIZED Authentication is missing or invalid.
404 USER_NOT_FOUND The authenticated user was not found.
404 UNKNOWN_FUNCTION The requested API endpoint is unsupported.
413 PAYLOAD_TOO_LARGE The request body exceeds the limit for your plan.
429 QUOTA_EXCEEDED The plan’s request quota has been reached.
429 RATE_LIMITED The request rate limit has been reached.
500 PLAN_NOT_FOUND Plan configuration could not be found.
500 INTERNAL_ERROR The request could not be processed.

Notes

  • Body-size, quota, and rate limits depend on your plan. See tool limits.
  • Send text directly in the request body; this endpoint does not require a JSON request body.