COPY API Endpoint

Version 2.197 (Release Notes ↗)

Description

Copy media from a remote location and store it on Pixlab's storage server or your AWS S3 bucket. Copy a media from a remote location and store it on the pixlab.xyz storage server. If you have already set your own AWS S3 keys (refer to your dashboard ↗ on how to do that), then the media shall be copied to your S3 bucket.

HTTP Methods

GET

HTTP Parameters

Required

Fields Type Description
link URL Input media URL or Unique ID.
key String Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

HTTP Response

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the media output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ on how to do that).
id String Unique media ID.
error String Error message if status != 200.

Code Samples


import requests


def copy_image_to_bucket(image_url: str, api_key: str) -> str:
    """Copy an image to the PixLab bucket and return the new URL."""
    response = requests.get(
        'https://api.pixlab.io/copy',
        params={
            'img': image_url,
            'key': api_key
        },
        timeout=10
    )
    response.raise_for_status()
    data = response.json()
    
    if data['status'] != 200:
        raise ValueError(data.get('error', 'Unknown error occurred'))
    
    return data['link']


if __name__ == '__main__':
    try:
        copied_url = copy_image_to_bucket(
            image_url='http://cf.broadsheet.ie/wp-content/uploads/2015/03/jeremy-clarkson_3090507b.jpg',
            api_key='My_PIXLAB_API_KEY'
        )
        print(f"Copied image: {copied_url}")
    except requests.exceptions.RequestException as e:
        print(f"Request failed: {e}")
    except ValueError as e:
        print(f"API error: {e}")
← Return to API Endpoint Listing