Image

Image to Base64

0calls
2 credits / call

See a picture on the web and want to convert it to Base64 encoding so you can embed it in your HTML or CSS? This endpoint is for you.

GET
uapis.cn
/api/v1/image/tobase64
Query parameters
1
url
string
required

The publicly accessible image URL address that needs to be converted to Base64.

Overview

You provide a publicly accessible image URL, we help you download it and convert it to a Base64 Data URI string containing MIME type and return it to you.

Query parameters

url
stringrequired

The publicly accessible image URL address that needs to be converted to Base64.

Response

200 / OK

Conversion successful! Returns a JSON object containing the Base64 encoded string.

JSON
{
  // The complete Base64 Data URI after conversion, ready to use in CSS or HTML.
  "base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
  // Operation result description.
  "msg": "success"
}

400 / Bad Request

Request parameter error. Please check if you provided the url parameter and if it is a valid URL format.

JSON
{
  "code": "INVALID_ARGUMENT",
  "details": {},
  "message": "Missing or invalid 'url' parameter."
}

502 / Bad Gateway

Failed to retrieve image. We were unable to download the image from the provided URL. Please check if the URL is publicly accessible and points to a valid image resource.

JSON
{
  "code": "UPSTREAM_ERROR",
  "details": {},
  "message": "Failed to fetch image from the provided URL."
}