PixSpeed API

The first 500 compressions each month are free.

Sign up now

The PixSpeed API allows you to compress and optimize images in formats such as WebP, JPEG, PNG, and AVIF. Designed as a RESTful service, PixSpeed's API enables seamless integration for image optimization across web applications. This page provides details on the core HTTP API. Additionally, we are developing client libraries in various languages to simplify interactions with the PixSpeed API.

The API is hosted at api.pixspeed.com.


Authentication

To access the PixSpeed API, you must include your unique API key. You can obtain an API key by signing up with your name and email address. Please remember to keep your API key confidential.

Authentication with the API is handled through HTTP headers. All requests require an Authorization header containing your API key in the format key: YOUR_API_KEY, where YOUR_API_KEY is the key available on your account page.

For security, all requests must be sent over an encrypted HTTPS connection to protect your data during transmission.


Compressing Images

You can provide any WebP, JPEG, or PNG image URL to the PixSpeed API for compression. PixSpeed will automatically detect the image type and apply optimal compression. Compression begins as soon as you provide the URL.

Example Using URL for Compression

To use PixSpeed with an image URL, replace YOUR_API_KEY with your unique API key (found on your PixSpeed account page) and specify the image URL in JSON format as shown below:

curl -X POST https://api.pixspeed.com/v1/url \
     -H "Content-Type: application/json" \
     -H "key: YOUR_API_KEY" \
     -d '{"url": "https://example.com/path/to/your-image.jpg"}'

PixSpeed will retrieve the image from the provided URL, compress it, and return the optimized version URL in the response.


Optimizing and Converting Images

With the PixSpeed API, you can not only compress images but also convert them to different formats. PixSpeed will automatically optimize the image and, if a format is specified, convert it to the desired type. Supported formats include jpg, jpeg, png, webp, and avif. If no format is specified, PixSpeed will retain the original format of the image.

Example Using cURL with an Image URL and Format

To use PixSpeed to optimize and convert an image, replace YOUR_API_KEY with your unique API key and specify the image URL and desired format in JSON format as shown below. The format can be any of the supported formats (jpg, jpeg, png, webp, or avif), and PixSpeed will convert the image accordingly.

curl -X POST https://api.pixspeed.com/v1/url \
     -H "Content-Type: application/json" \
     -H "key: YOUR_API_KEY" \
     -d '{"url": "https://example.com/path/to/your-image.jpg", "format": "webp"}'

PixSpeed will optimize the image from the provided URL, convert it to webp, and return the optimized version’s URL in the response.

🖼️ Total images optimized

5794