API Documentation

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

Introduction

The Resale-x API allows you to classify 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

/classification

Upload images for product classification.

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

/classification/{classification_id}

Retrieve the current status, result, and any error message for a specific classification task. Poll this endpoint until status is DONE.

{
  "client_id": "your-client-id",
  "classification_id": "uuid"
}
POST

/task

Create a classification task directly.

{
  "client_id": "string",
  "classification_id": "uuid (optional)",
  "brand": "string",
  "item": "string",
  "category": "string",
  "model": "string",
  "color": "string",
  "condition": "string",
  "country": "string (default: us)",
  "year": "string (default: 2025)"
}
GET

/task/{task_id}

Retrieve the current status, result, and any error message for a specific task. Poll this endpoint until status is DONE.

{
  "client_id": "string",
  "task_id": "uuid"
}
GET

/tasks

Retrieve the history of tasks.

{
  "client_id": "string (required)",
  "page": "integer (optional, default: 1)",
  "limit": "integer (optional, default: 20)",
  "response_type": "string (optional, 'card' or 'full', default: 'card')"
}

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 with the uploaded image URL
    const classificationResponse = await fetch('https://hub.resale-x.com/api/classification', {
      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

curl -X POST https://hub.resale-x.com/api/classification \
  -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 classification to task creation

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

// Create a classification with the uploaded image
const classificationResponse = await fetch('https://hub.resale-x.com/api/classification', {
  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 { classification_id } = await classificationResponse.json();

4. Check classification status

// Poll classification status until complete
let classificationComplete = false;
let classificationResult;

while (!classificationComplete) {
  const statusResponse = await fetch(
    `https://hub.resale-x.com/api/classification/${classification_id}`,
    {
      headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }
    }
  );
  
  classificationResult = await statusResponse.json();
  
  if (classificationResult.status === 'DONE') {
    classificationComplete = true;
  } else {
    // Wait before polling again
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
}

5. Create task with classification data

// Create a task with the classification data
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',
    classification_data: classificationResult.result,
    country: 'us'
  })
});

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

6. 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 === 'DONE') {
    taskComplete = true;
  } else {
    // Wait before polling again
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
}

7. View task history

// Get task history
const tasksResponse = await fetch(
  'https://hub.resale-x.com/api/tasks',
  {
    headers: { 'Authorization': 'Bearer YOUR_TOKEN_HERE' }
  }
);

const tasksData = await tasksResponse.json();
console.log(tasksData);