Site icon Efficient Coder

Automate Your Success on Xianyu: AI Tools & API Solutions for Smarter Trading

Automated Xianyu Trading: AI-Powered Monitoring Bot and Search API Solutions

In today’s digital marketplace, automating secondhand trading platforms gives you a competitive edge on Xianyu. This comprehensive guide explores two distinct approaches: an AI-enhanced visual monitoring tool for consumers and a developer-friendly search API.

The Need for Xianyu Automation Tools

As China’s leading secondhand marketplace, Xianyu hosts thousands of high-value deals daily. Manual monitoring presents significant challenges:

  • Time-consuming product searches
  • Missed opportunities on limited-time offers
  • Difficulty verifying product authenticity
  • Inefficient price comparisons

Automation solutions address these pain points by:

  • Providing 24/7 product monitoring
  • Implementing AI-powered quality verification
  • Delivering instant restock notifications
  • Preventing substandard purchases

Solution 1: Xianyu AI Monitoring Bot

Core Functionality Highlights

This Playwright and OpenAI-based solution offers a complete visual interface requiring no programming skills:

  • 🖥️ Comprehensive Web Dashboard: Unified task management, logging, and results filtering
  • 🤖 Natural Language Task Creation: Automatically converts purchase requirements into monitoring rules

    Example: “Find Sony A7M4 cameras over 95% new condition under ¥13,000 with <5,000 shutter count”

  • 🔔 Multi-platform Notifications: Push alerts to mobile/desktop via ntfy
  • 🚀 Concurrent Multi-task Monitoring: Simultaneously track multiple product categories
  • 🛡️ Intelligent Anti-Blocking: Simulates human interaction patterns

Technical Architecture Breakdown

Component Function
Playwright Browser automation control
FastAPI Web service framework
OpenAI GPT-4o Multimodal product analysis
ntfy Cross-platform notifications
JSONL Data storage format

Four-Step Implementation Guide

Step 1: Environment Setup

git clone https://github.com/dingyufei615/ai-goofish-monitor
cd ai-goofish-monitor
pip install -r requirements.txt

Step 2: Essential Configuration

Create .env file with:

OPENAI_API_KEY="your_api_key" 
OPENAI_BASE_URL="https://api.openai.com/v1"
OPENAI_MODEL_NAME="gpt-4o"
NTFY_TOPIC_URL="https://ntfy.sh/your-topic"

Step 3: Xianyu Authentication

python login.py

Authenticate by scanning the QR code with Xianyu mobile app

Step 4: Launch Service

python web_server.py

Access dashboard at http://127.0.0.1:8000

Web Interface Walkthrough

Task Management Center

Task Management Interface
  • AI-Assisted Setup: Natural language to monitoring rules conversion
  • Real-time Status Tracking: Visual task operation indicators
  • Batch Operations: One-click start/stop for all tasks

Product Results Display

Product Monitoring Interface
  • Card-Based Layout: Visual product presentation
  • AI Recommendations: Smart highlighting of high-value items
  • Detail Inspection: Full analysis reports

Mobile Notification Sample


Instant AI-verified product alerts

Advanced Command Line Operations

Task Creation

python prompt_generator.py \
  --description "Sony A7M4 over 95% new under ¥13k" \
  --output prompts/sony_a7m4.txt \
  --task-name "Sony Monitor" \
  --keyword "a7m4" \
  --min-price "10000" \
  --max-price "13000"

Debug Mode Execution

python spider_v2.py --debug-limit 2

Workflow Visualization

graph TD
    A[Start Monitoring] --> B[Search Target Products]
    B --> C{New Items Found?}
    C -- Yes --> D[Scrape Details]
    D --> E[Download Images]
    E --> F[AI Multi-factor Analysis]
    F --> G{Recommended?}
    G -- Yes --> H[Send Mobile Notification]
    H --> I[Save Analysis]
    G -- No --> I
    C -- No --> J[Wait/Paginate]
    J --> B

Project Structure Overview

ai-goofish-monitor/
├── web_server.py       # Web service entry
├── spider_v2.py        # Core crawling logic
├── prompts/            # AI rule repository
├── config.json         # Task configuration
├── login.py            # Authentication module
└── images/             # Product image cache

Solution 2: Xianyu Product Search API

Core Technical Features

This FastAPI-based solution targets developers:

  • Asynchronous Processing: Handles dozens of requests/second
  • 🧩 Plug-and-Play API: RESTful endpoint design
  • 🧠 Smart Deduplication: Hash-based duplicate detection
  • 💾 Data Persistence: MySQL database storage
  • 📊 Result Analytics: New item count reporting

Technology Stack Composition

Component Function
FastAPI API framework
Playwright Headless browser control
Tortoise ORM Async database operations
MySQL Persistent data storage
Uvicorn ASGI server

Implementation Guide

1. Environment Initialization

pip install -r requirements.txt
playwright install chromium

2. Database Configuration

Create .env file:

DATABASE_URL=mysql://user:password@localhost/xianyu

3. Service Launch

python spider.py

API Documentation

Search Endpoint

POST /search/

Request Example:

{
  "keyword": "digital camera",
  "max_pages": 3
}

Response Example:

{
  "status": "success",
  "keyword": "digital camera",
  "total_results": 45,
  "new_records": 8,
  "new_record_ids": [201,202,205,209,210,215,218,220]
}

Client Implementation Samples

cURL Request

curl -X POST "http://localhost:8000/search/" \
-H "Content-Type: application/json" \
-d '{"keyword": "laptop", "max_pages": 2}'

Python Integration

import requests

response = requests.post(
    "http://localhost:8000/search/",
    json={"keyword": "mechanical keyboard", "max_pages": 1}
)
print(response.json())

Performance Optimization

  1. Database Tuning:

    • Configure connection pooling
    • Implement data archiving
  2. Anti-Scraping Measures:

    • Use proxy IP rotation
    • Implement randomized delays
    • Simulate human interaction patterns
  3. Caching Implementation:

    • Add Redis caching layer
    • Enable request result caching

Solution Comparison

Feature AI Monitoring Bot Search API
Target Users General consumers Developers
Complexity Low (visual interface) Medium (programming required)
Core Function AI recommendations + alerts Data collection + storage
Technical Barrier Basic computer skills API integration knowledge
Output Format Visual alerts + local storage Structured JSON
Ideal Use Case Personal deal hunting System integration

Frequently Asked Questions

How much does this cost?

Both projects are MIT-licensed open source tools. Note that OpenAI API usage incurs separate costs.

Will my account get banned?

Built-in safeguards include:

  • Randomized operation intervals
  • Human behavior simulation
  • Request throttling
    Excessive requests may still trigger restrictions.

What technical skills are required?

  • Monitoring Bot: Basic computer literacy
  • Search API: Command line and API integration knowledge

What notification methods are supported?

Currently supports ntfy.sh with delivery to:

  • iOS/Android apps
  • Desktop browsers
  • Email clients
  • Telegram and other messaging platforms

How can I extend functionality?

Both projects feature modular designs:

  1. Monitoring Bot: Modify spider_v2.py core logic
  2. Search API: Extend /search/ endpoint
    Well-documented code simplifies customization.

Real-World Applications

Case Study: Photography Equipment

A photographer configured:

"Find Canon 5D4 over 95% new condition
Under ¥6,500 with <20k shutter count
Full packaging, exclude professional sellers"

Discovered a qualified item within 72 hours, saving ¥1,200 after AI verification.

Case Study: Price Monitoring

An e-commerce company:

  1. Hourly price checks via Search API
  2. Data warehousing for analysis
  3. Market trend reporting
    Optimized pricing strategy for their secondhand inventory.

Future Development Directions

  1. Notification Expansion:

    • Add WeChat/DingTalk integration
    • Implement email alerts
  2. Analytics Enhancement:

    • Multi-AI provider support (Claude/Gemini)
    • Historical price tracking
  3. Deployment Improvements:

    • Docker containerization
    • One-click cloud deployment

Conclusion

Whether you’re a consumer seeking deals or a developer needing Xianyu integration, these solutions deliver:

  1. AI Monitoring Bot – Your 24/7 personal shopping assistant
  2. Product Search API – Instant marketplace data integration

Important: Use tools in compliance with China’s Cybersecurity Law and Xianyu’s platform policies. Both projects are actively maintained – star their repositories for updates.

pie
    title Tool Usage Distribution
    “Personal Monitoring” : 65
    “Price Analysis” : 20
    “Market Research” : 10
    “Other Applications” : 5

Automation transforms secondhand trading by saving time, preventing mistakes, and maximizing value. For technical support, visit the projects’ issue trackers.

Exit mobile version