🚀 We're launching Video Optimization in beta! Read the announcement.

Writing API requests

Learn to write requests to the TwicPics media transformation API.

TwicPics is powered by a URL-based API that can be used to transform and manipulate images. When using the script or the components, the API request is generated using your browser context. But in some cases, you might want to write the API requests yourself.

URL format

In order to perform an API call to TwicPics you need to provide:

The URL for an API request has the following format:

https://<sub>.twic.pics/<path_to_image>?twic=v1/<manipulation>

Where:

  • https://<sub>.twic.pics/<path_to_image> is the image path
  • ?twic=v1/<manipulation> is a list of one or more transformations
Transformations are always applied in order. See Chaining transformations.

For instance, provided the root (/) of subdomain <sub> points to http://mydomain.com/, https://<sub>.twic.pics/myImage.png?twic=v1/resize=450 will redimension http://mydomain.com/myimage.png to a width of 450 pixels while preserving its aspect ratio.

If you wish to pass query parameters to the server delivering the source image, just add it to the query string before or after the manipulation using the usual query string separator &.

Going back to the previous example but, this time, wanting to manipulate http://mydomain.com/myimage.png?param=value you could use one of these two options:

  • https://<sub>.twic.pics/myImage.png?twic=v1/resize=450&param=value
  • https://<sub>.twic.pics/myImage.png?param=value&twic=v1/resize=450
On this page
responsive images

The All-In-One Toolbox For Your Medias

The simplest, most powerful way to tackle responsive images & videos