API Documentation

Complete reference guide for the Resale-X API for classifying and pricing fashion items

Introduction

The Resale-x API allows you to classify and price fashion items in the secondary market. This documentation provides all the information you need to integrate with our API.

Base URL

All API endpoints are accessible via the following base URL:

https://hub.resale-x.com/api/

Use this URL as a prefix for all endpoints described in this documentation.

Authentication

The API uses Bearer token authentication. You need to obtain a token before making requests.

Obtaining a Bearer Token

Send a request to the authorization endpoint to get an access token

Make a POST request to the https://hub.resale-x.com/api/token endpoint with your client credentials:

curl -X POST https://hub.resale-x.com/api/token \
  -H "Content-Type: application/json" \
  -d '{
    "client-id": "your-client-id",
    "client-secret": "your-client-secret"
  }'

Response example:

{
  "access_token": "eyJhb...."
}

Using Bearer Token Authentication

After obtaining the token, include the following header with all API requests:

Authorization: Bearer YOUR_TOKEN_HERE
⚠️Note:Keep your token secure. Don't expose it in client-side code.

API Endpoints

The main endpoints for interacting with the Classifier API.

Item Classification

Endpoints for creating and managing product classification tasks.

POST

/task

Upload images for product classification.

{
  "client_id": "string",
  "photo_links": [
    "string"
  ],
  "country": "string (default: us)"
}
GET

/task/{task_id}

Retrieve the current status, result, and any error message for a specific classification task.

{
  "task_id": "uuid (path parameter)"
}
PATCH

/task/{task_id}

Manually update specific fields of a classification task result.

{
  "task_id": "uuid (path parameter)",
  "body": {
    "brand": "string | null",
    "item": "string | null",
    "category": "string | null",
    "model": "string | null",
    "color": "string | null",
    "condition": "string | null"
  }
}

Item Pricing

Endpoints for retrieving and calculating product pricing information.

GET

/price/{task_id}

Fetch classification details by task_id, then calculate and return the price information.

{
  "task_id": "uuid (path parameter)"
}
POST

/price

Compute the price for a product either by referencing an existing task_id or by providing attributes directly.

{
  "task_id": "uuid | null",
  "brand": "string | null",
  "item": "string | null",
  "category": "string | null",
  "model": "string | null",
  "color": "string | null",
  "condition": "string | null"
}

Photos Processing

Endpoints for handling image uploads and processing.

GET

/upload-url

Generate a presigned URL for uploading an image directly to S3.

{}

Photo Upload Process

  1. Step 1: Get a presigned URL from the API.

    // Request a presigned URL
    const response = await fetch('https://hub.resale-x.com/api/upload-url', {
      headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }
    });
    
    const { upload_url, url } = await response.json();
    // upload_url: The URL to which you'll upload the file
    // url: The URL where the file will be accessible after upload
  2. Step 2: Upload your image file to the presigned URL.

    // Upload the file to the presigned URL
    const imageFile = /* your File object */;
    
    const uploadResponse = await fetch(upload_url, {
      method: 'PUT',
      body: imageFile,
      headers: {
        'Content-Type': imageFile.type
      }
    });
    
    if (!uploadResponse.ok) {
      throw new Error('Failed to upload image');
    }
  3. Step 3: Use the returned URL in your classification task.

    // Create a classification task with the uploaded image URL
    const taskResponse = await fetch('https://hub.resale-x.com/api/task', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN_HERE',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        client_id: 'your-client-id',
        photo_links: [url],  // Use the URL returned from the upload-url endpoint
        country: 'us'
      })
    });
⚠️Important:The presigned URL is temporary and will expire after a short period (typically 15 minutes). Upload your file immediately after obtaining the URL.

Request Examples

Examples showing how to use the API with different programming languages.

Creating a Classification Task

curl -X POST https://hub.resale-x.com/api/task \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "client_id": "your-client-id",
    "photo_links": ["https://example.com/image1.jpg"],
    "country": "us"
  }'

Complete API Flow Example

A complete workflow from creating a task to getting price data

1. Get upload URL

// Get presigned URL for image upload
const urlResponse = await fetch('https://hub.resale-x.com/api/upload-url', {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE'
  }
});

const { upload_url, url } = await urlResponse.json();

2. Upload image to S3

// Upload file to the presigned URL
const imageFile = /* your file object */;
await fetch(upload_url, {
  method: 'PUT',
  body: imageFile,
  headers: {
    'Content-Type': imageFile.type
  }
});

3. Create classification task

// Create a classification task with the uploaded image
const taskResponse = await fetch('https://hub.resale-x.com/api/task', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    client_id: 'your-client-id',
    photo_links: [url], // URL from step 1
    country: 'us'
  })
});

const { task_id } = await taskResponse.json();

4. Check task status

// Poll task status until complete
let taskComplete = false;
let taskResult;

while (!taskComplete) {
  const statusResponse = await fetch(
    `https://hub.resale-x.com/api/task/${task_id}`, 
    {
      headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }
    }
  );
  
  taskResult = await statusResponse.json();
  
  if (taskResult.status === 'completed' || 
      taskResult.status === 'failed') {
    taskComplete = true;
  } else {
    // Wait before polling again
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
}

5. Get price data

// Get price data for the classified item
const priceResponse = await fetch(
  `https://hub.resale-x.com/api/price/${task_id}`,
  {
    headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }
  }
);

const priceData = await priceResponse.json();
console.log(priceData);