Skip to content

Latest commit

 

History

History
234 lines (164 loc) · 5.13 KB

File metadata and controls

234 lines (164 loc) · 5.13 KB

RapidAPI 1688 Integration Guide

✅ You're Using RapidAPI!

This is a great choice - much easier than direct 1688 API integration!


🔑 Your Credentials

Service: 1688-product2 on RapidAPI API Key: 46b8092e0dmsh4608b3761d133cep1d3661jsn400867a11bd8 Host: 1688-product2.p.rapidapi.com

✅ Already configured in .env.local


📚 Step 1: Check Available Endpoints

Visit your RapidAPI dashboard to see all available endpoints:

URL: https://rapidapi.com/hub

Look for:

  1. Product Search endpoint
  2. Product Details endpoint
  3. Category List endpoint
  4. Image Search endpoint (if available)

Common endpoint patterns:

GET  /1688/product/search
GET  /1688/product/detail
POST /1688/tools/image/search
POST /1688/tools/image/convert_url  ✅ (You have this!)
GET  /1688/category/list

🔧 Step 2: Update API Routes

I've created src/lib/rapidapi-1688.ts with helper functions.

You need to:

  1. Check the actual endpoint names in RapidAPI dashboard
  2. Update the endpoint URLs in rapidapi-1688.ts if they differ
  3. Update the API routes to use RapidAPI instead of mock data

📝 Step 3: Test the Image Convert Endpoint

Let's test the endpoint you already have:

curl --request POST \
  --url https://1688-product2.p.rapidapi.com/1688/tools/image/convert_url \
  --header 'Content-Type: application/json' \
  --header 'x-rapidapi-host: 1688-product2.p.rapidapi.com' \
  --header 'x-rapidapi-key: 46b8092e0dmsh4608b3761d133cep1d3661jsn400867a11bd8' \
  --data '{"url":"https://picsum.photos/400/400"}'

Expected response:

  • Converted image URL from 1688
  • Or error message if image not found

🔄 Step 4: Find Product Search Endpoint

On RapidAPI dashboard:

  1. Go to your subscription: 1688-product2
  2. Click Endpoints tab
  3. Look for endpoints like:
    • search
    • product/search
    • item/search
    • goods/search

Once you find it, tell me:

  • Endpoint path (e.g., /1688/product/search)
  • Method (GET or POST)
  • Required parameters
  • Response format

🎯 Step 5: Update the Code

Once you know the endpoints, I'll update these files:

Files to update:

  1. src/lib/rapidapi-1688.ts - Update endpoint URLs
  2. src/app/api/products/route.ts - Use RapidAPI instead of mock data
  3. src/app/api/products/[id]/route.ts - Use RapidAPI for details
  4. src/app/api/search/image/route.ts - Use your image search endpoint

📊 Response Format

Typical RapidAPI 1688 response:

{
  "code": 0,
  "message": "success",
  "data": {
    "total": 100,
    "items": [
      {
        "productId": "12345",
        "title": "Product Name",
        "price": 99.99,
        "imageUrl": "https://...",
        "supplierName": "Supplier Co.",
        "moq": 100
      }
    ]
  }
}

Your app expects:

{
  "success": true,
  "products": [...],
  "total": 100,
  "page": 1,
  "pageSize": 20
}

We'll create a transformer to convert RapidAPI format to your app format.


💰 Pricing Check

Important: Check your RapidAPI plan limits!

On RapidAPI dashboard:

  1. Go to Billing or My Subscriptions
  2. Check your plan:
    • Free tier: Usually 100-500 requests/month
    • Basic: ~$10-30/month, 5,000-10,000 requests
    • Pro: ~$50-100/month, unlimited or high limits

Your app needs: ~500-1,000 requests/day

Make sure your plan supports this!


🧪 Testing Checklist

Before going live, test:

  • Image convert endpoint works
  • Product search returns real data
  • Product details work
  • Images load correctly
  • Supplier information included
  • Price data is accurate
  • Category filtering works
  • No rate limit errors

🚀 Quick Start (After Finding Endpoints)

1. Test your API key:

curl --request GET \
  --url "https://1688-product2.p.rapidapi.com/1688/product/search?keyword=phone" \
  --header "x-rapidapi-host: 1688-product2.p.rapidapi.com" \
  --header "x-rapidapi-key: 46b8092e0dmsh4608b3761d133cep1d3661jsn400867a11bd8"

2. Check the response format

3. Tell me the endpoint details

4. I'll update all the code

5. Restart server and test!


📞 Need Help?

If the API documentation is unclear:

  1. Check RapidAPI "Code Snippets" tab - shows examples
  2. Check "Response" tab - shows example responses
  3. Contact RapidAPI support - they're helpful
  4. Share the endpoint details with me - I'll help integrate

⚠️ Common Issues

Issue: "Rate limit exceeded"

Solution: Upgrade your RapidAPI plan or wait for reset

Issue: "Invalid API key"

Solution: Regenerate key on RapidAPI dashboard

Issue: "Endpoint not found"

Solution: Check exact endpoint path in API documentation

Issue: "Response format doesn't match"

Solution: We'll create a transformer function


🎉 Next Steps

  1. Visit RapidAPI dashboard and check all available endpoints
  2. Test the product search endpoint (find it first!)
  3. Share endpoint details with me
  4. I'll complete the integration for you
  5. Test and launch! 🚀

You're almost there! Just need to find the product search endpoint!