REST API No Watermark High Accuracy Real-time

Virtual Try-On API

The Virtual Try-On API enables developers to integrate realistic virtual try-on capabilities into their applications, enhancing user interactivity and engagement on e-commerce platforms.

Why Use This API

Realistic Rendering

Present highly accurate and realistic virtual try-ons that align with physical attributes, enhancing the shopping experience.

Real-time Processing

Integrate swift, real-time image processing to prevent latency issues and maintain user engagement with the platform.

Secure Transactions

Utilize secure, encrypted connections to protect user information and maintain compliance with data privacy regulations.

Scalable and Reliable

Handle varying loads efficiently with scalable endpoints suitable for growing e-commerce environments.

Quick Start

Get started in under a minute:

  1. Register Your API Key — Sign up for an account and access your unique API key to authenticate requests.
  2. Integrate with Your Application — Use our detailed documentation and code examples to integrate quickly with your e-commerce platform.
  3. Validate and Launch — Test your integration thoroughly and deploy live to offer virtual try-on capabilities.
curl -X POST 'https://precisioncounter.com/api/v1/virtual-try-on' -H 'Authorization: Bearer YOUR_API_KEY' -F 'image=@path/to/image.jpg' -F 'user_attributes={"skin_tone":"light"}' -F 'category=glasses'
import requests

api_url = 'https://precisioncounter.com/api/v1/virtual-try-on'
files = {'image': open('path/to/image.jpg', 'rb')}
data = {'user_attributes': '{"skin_tone":"light"}', 'category': 'glasses'}
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
response = requests.post(api_url, files=files, data=data, headers=headers)
print(response.json())
const fetch = require('node-fetch');
const fs = require('fs');

const apiUrl = 'https://precisioncounter.com/api/v1/virtual-try-on';
const formData = new FormData();
formData.append('image', fs.createReadStream('path/to/image.jpg'));
formData.append('user_attributes', '{"skin_tone":"light"}');
formData.append('category', 'glasses');

fetch(apiUrl, {
  method: 'POST',
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
  body: formData
})
  .then(response => response.json())
  .then(data => console.log(data));

API Reference

Base URL

https://precisioncounter.com/api/v1

Authentication

All requests require an API key passed in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Virtual Try-On

POST /api/v1/virtual-try-on

Processes images to provide virtual try-on experiences tailored to user specifications for apparel, cosmetics, or accessories.

Request Parameters

Parameter Type Description
image required file The image file of the product or accessory to apply in the virtual try-on.
user_attributes required string JSON string of user-specific attributes like skin tone or face shape for personalized results.
category required string The category of the item, such as 'glasses', 'hat', or 'makeup'.
api_key required string Your unique API key assigned to your account to authenticate the request.

Response

200 OK — A successful response contains a URL of the processed image with a virtual overlay applied.

Response Headers

Header Value
Content-Type Indicates the media type of the resource.
Content-Length The size of the response body in bytes.
X-Request-ID A unique identifier for the request, useful for tracking.

Code Examples

import requests
import os

def virtual_try_on(image_path, user_attributes, category):
    api_url = 'https://precisioncounter.com/api/v1/virtual-try-on'
    try:
        with open(image_path, 'rb') as image_file:
            files = {'image': image_file}
            data = {'user_attributes': user_attributes, 'category': category}
            headers = {'Authorization': 'Bearer YOUR_API_KEY'}
            response = requests.post(api_url, files=files, data=data, headers=headers)
            response.raise_for_status()
            return response.json()
    except requests.exceptions.RequestException as e:
        print(f'Request failed: {e}')

# Example Usage
try_on_result = virtual_try_on('path/to/image.jpg', '{"skin_tone":"light"}', 'glasses')
print(try_on_result)
const fetch = require('node-fetch');
const fs = require('fs');

async function virtualTryOn(imagePath, userAttributes, category) {
  const apiUrl = 'https://precisioncounter.com/api/v1/virtual-try-on';
  const formData = new FormData();
  formData.append('image', fs.createReadStream(imagePath));
  formData.append('user_attributes', userAttributes);
  formData.append('category', category);

  try {
    const response = await fetch(apiUrl, {
      method: 'POST',
      headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
      body: formData
    });
    if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error('Error:', error);
  }
}

// Example Usage
virtualTryOn('path/to/image.jpg', '{"skin_tone":"light"}', 'glasses');
<?php
function virtual_try_on($image_path, $user_attributes, $category) {
    $api_url = 'https://precisioncounter.com/api/v1/virtual-try-on';
    $curl = curl_init();
    $headers = ['Authorization: Bearer YOUR_API_KEY'];

    $file = new CURLFile($image_path);
    $postFields = array('image' => $file, 'user_attributes' => $user_attributes, 'category' => $category);

    curl_setopt_array($curl, [
        CURLOPT_URL => $api_url,
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => $postFields,
        CURLOPT_HTTPHEADER => $headers
    ]);

    $response = curl_exec($curl);
    $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);

    if ($httpcode >= 200 && $httpcode < 300) {
        return json_decode($response, true);
    } else {
        return 'Request failed with status code ' . $httpcode;
    }
}

// Example Usage
$result = virtual_try_on('path/to/image.jpg', '{"skin_tone":"light"}', 'glasses');
print_r($result);
?>
package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"mime/multipart"
	"net/http"
	"os"
)

func virtualTryOn(imagePath, userAttributes, category string) {
	apiUrl := "https://precisioncounter.com/api/v1/virtual-try-on"

	file, err := os.Open(imagePath)
	if err != nil {
		fmt.Println("Error opening file:", err)
		return
	}
	defer file.Close()

	var requestBody bytes.Buffer
	writer := multipart.NewWriter(&requestBody)
	part, err := writer.CreateFormFile("image", file.Name())
	if err != nil {
		fmt.Println("Error creating form file:", err)
		return
	}
	_, err = io.Copy(part, file)

	_ = writer.WriteField("user_attributes", userAttributes)
	_ = writer.WriteField("category", category)

	writer.Close()

	req, err := http.NewRequest("POST", apiUrl, &requestBody)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}
	req.Header.Add("Content-Type", writer.FormDataContentType())
	req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error sending request:", err)
		return
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error reading response body:", err)
		return
	}
	fmt.Println(string(body))
}

func main() {
	virtualTryOn("path/to/image.jpg", "{\"skin_tone\":\"light\"}", "glasses")
}
require 'net/http'
require 'uri'
require 'json'
require 'mime'

uri = URI.parse('https://precisioncounter.com/api/v1/virtual-try-on')

request = Net::HTTP::Post.new(uri)
request.content_type = 'multipart/form-data'
request['Authorization'] = 'Bearer YOUR_API_KEY'

form_data = [['image', File.open('path/to/image.jpg')]]
form_data << ['user_attributes', '{"skin_tone":"light"}']
form_data << ['category', 'glasses']

request.set_form form_data, 'multipart/form-data'

req_options = { use_ssl: uri.scheme == 'https' }

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end

puts response.body
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        string apiUrl = "https://precisioncounter.com/api/v1/virtual-try-on";
        var client = new HttpClient();
        var form = new MultipartFormDataContent();
        form.Add(new ByteArrayContent(System.IO.File.ReadAllBytes("path/to/image.jpg")), "image", "image.jpg");
        form.Add(new StringContent("{\"skin_tone\":\"light\"}"), "user_attributes");
        form.Add(new StringContent("glasses"), "category");

        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");

        try
        {
            var response = await client.PostAsync(apiUrl, form);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Request error: {e.Message}");
        }
    }
}

Error Handling

The API returns standard HTTP status codes with JSON error bodies:

Status Meaning Description
200 Success The request was successful and the virtual try-on is processed.
400 Bad Request The request was unacceptable, often due to a missing or misformatted parameter.
401 Unauthorized Authentication failed, the API key was not valid or not provided.
429 Too Many Requests The request was rejected due to hitting the rate limit for your plan.
500 Server Error The server encountered an unexpected condition which prevented it from fulfilling the request.

Error Response Format

{
  "error": "Description of what went wrong",
  "code": "ERROR_CODE",
  "status": 400
}

Rate Limits

Plan Requests / Minute Max File Size Max Resolution
Free 30 2MB 1080p
Pro 100 10MB 4K

Rate limit headers are included in every response:

X-RateLimit-Limit: 10
X-RateLimit-Remaining: 7
X-RateLimit-Reset: 1708646400

Use Cases

  • Virtual Eyewear
  • Apparel Fittings
  • Cosmetic Try-Ons
  • Hat Try-Ons
  • Jewelry Fittings
  • Footwear
  • Promotions
  • E-commerce

Pricing

Free to Start

Get free API credits when you sign up. No credit card required.

Frequently Asked Questions

What types of images are supported?
Our API supports standard image formats such as JPEG, PNG, and BMP to ensure broad compatibility and ease of use.
Is there a free tier available?
Yes, a free tier is available, providing 30 requests per minute with a maximum image resolution of 1080p for testing and small-scale applications.
How secure is the platform?
Security is a core feature. All API transactions are encrypted via HTTPS, and user data is safeguarded according to industry best practices.
Can I use this for live events?
Absolutely! Our real-time processing is designed to support interactive live events without noticeable delays, enhancing guest engagement.
How does the API handle errors?
The API provides detailed error responses via HTTP status codes and accompanying messages, enabling your team to troubleshoot effectively.
What customization is possible?
Customization allows you to define user-specific attributes such as skin tone or face shape to tailor the virtual try-on results precisely to their needs.