All Collections
Working with the API for Photo Editing
Sample code and integration examples
Sample code and integration examples
Jamie McInally avatar
Written by Jamie McInally
Updated over a week ago

Integrating our AI photo editing service's API into your applications can greatly streamline your real estate image editing process. In this article, we'll provide sample code and integration examples in Python and JavaScript to help you get started.

Python Example:

To use our API in Python, you can use the popular requests library. First, install the library using pip:

pip install requests

Next, you can use the following sample code to request our API:

import requests
import json

# Replace with your API key and image name
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.autoenhance.ai/v2/'
IMAGE_NAME = 'test.jpg'

#Set headers and payload
headers = {
"Content-Type":"application/json",
"x-api-key": API_KEY
}
data = {
"image_name": IMAGE_NAME,
"content_type": "image/jpeg"
}


#Get s3PutObjectUrl
req = requests.post(BASE_URL + 'image', headers=headers, json=data).json()
s3PutObjectUrl = req['s3PutObjectUrl']

#Set header for upload
headers = {"Content-Type": "image/jpeg"}

# Read image file
with open(IMAGE_NAME, 'rb') as image_file:
req2 = requests.put(url, headers=headers, data=image_file)

These sample code snippets demonstrate how to make a basic API request to our AI photo editing service in Python. Please take a look at our API documentation and adjust the code accordingly for more complex integrations or specific use cases. If you have any questions or need any more help, please refer to our help centre articles or contact our customer support team.

Did this answer your question?