Skip to content

Latest commit

Β 

History

History
296 lines (228 loc) Β· 9.92 KB

File metadata and controls

296 lines (228 loc) Β· 9.92 KB

πŸ“š MarketWay Navigator - API Documentation Suite

Complete documentation package for frontend engineers working with the MarketWay Navigator API.


πŸ“– Documentation Files

1. API_DOCUMENTATION.md - Complete API Reference

  • What it contains: Full API documentation with all endpoints, request/response schemas, data models, and code examples
  • When to use: When you need detailed information about any endpoint, including all parameters, response fields, and error codes
  • Best for: Reference during development, understanding API capabilities

2. API_QUICK_REFERENCE.md - Quick Start Guide

  • What it contains: Concise examples, TypeScript types, React hooks, and common patterns
  • When to use: When you need quick code snippets or want to get started fast
  • Best for: Copy-paste examples, quick lookups, troubleshooting common issues

3. FRONTEND_INTEGRATION_GUIDE.md - Integration Guide

  • What it contains: Practical integration examples for React, Vue.js, and vanilla JavaScript
  • When to use: When setting up your frontend project to consume the API
  • Best for: Project setup, implementing API clients, creating reusable hooks/composables
  • What it contains: Pre-configured API requests for all endpoints
  • When to use: For testing API endpoints without writing code
  • Best for: API exploration, manual testing, sharing with team members

πŸš€ Quick Start

For Frontend Engineers

  1. First Time? Start here:

    1. Read: API_QUICK_REFERENCE.md (5 min)
    2. Import: MarketWay_API.postman_collection.json into Postman
    3. Test: Try a few endpoints in Postman
    4. Integrate: Follow FRONTEND_INTEGRATION_GUIDE.md for your framework
    
  2. Need Details? Check:

    API_DOCUMENTATION.md β†’ Full endpoint specifications
    
  3. Building a Feature? Use:

    FRONTEND_INTEGRATION_GUIDE.md β†’ Copy component examples
    API_QUICK_REFERENCE.md β†’ Get TypeScript types
    

🎯 Common Use Cases

"I want to search for products"

// Quick example from API_QUICK_REFERENCE.md
fetch('http://127.0.0.1:8000/product/search?q=shoes')
  .then(res => res.json())
  .then(data => console.log(data.results));

πŸ“„ See: API_QUICK_REFERENCE.md β†’ Quick Examples β†’ Search Products

"I need to build a chat interface"

// Full component example in FRONTEND_INTEGRATION_GUIDE.md
import { useAsk } from '../hooks/useMarketApi';
// ... complete component code

πŸ“„ See: FRONTEND_INTEGRATION_GUIDE.md β†’ React Integration β†’ Chat Component

"What's the response format for /ask?"

{
  "answer": "string",
  "source": "local" | "online" | "combined",
  "images": ["string"]
}

πŸ“„ See: API_DOCUMENTATION.md β†’ POST /ask β†’ Response

"How do I handle file uploads?"

const formData = new FormData();
formData.append('file', audioBlob, 'query.wav');
fetch('/voice/query', { method: 'POST', body: formData });

πŸ“„ See: API_QUICK_REFERENCE.md β†’ Voice Query


πŸ“‹ API Endpoints Overview

Endpoint Method Purpose Documentation
/ask POST Ask questions about market Docs
/product/search GET Search for products Docs
/line/info/{name} GET Get line details Docs
/history GET Get market history Docs
/voice/query POST Voice interaction Docs
/image/identify POST Image recognition Docs
/navigate GET Get directions Docs

πŸ› οΈ Tools & Resources

Interactive API Documentation

http://127.0.0.1:8000/docs

Auto-generated Swagger UI for testing endpoints directly in your browser.

Postman Collection

Import MarketWay_API.postman_collection.json into Postman:

  1. Open Postman
  2. Click "Import"
  3. Select the JSON file
  4. Start testing!

Base URL

Local: http://127.0.0.1:8000
Production: https://your-api-domain.com

πŸ’‘ Tips for Success

βœ… Do's

  • βœ… Use the Postman collection to test endpoints before coding
  • βœ… Implement error handling for all API calls
  • βœ… Debounce search inputs to reduce API calls
  • βœ… Cache responses for frequently accessed data (like history)
  • βœ… Use TypeScript types from the documentation
  • βœ… Encode URL parameters (especially line names with spaces)

❌ Don'ts

  • ❌ Don't forget Content-Type headers for JSON requests
  • ❌ Don't use FormData for JSON endpoints (only for file uploads)
  • ❌ Don't make API calls on every keystroke (use debouncing)
  • ❌ Don't hardcode the API URL (use environment variables)
  • ❌ Don't ignore error responses

πŸ—οΈ Project Structure Example

your-frontend-project/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── client.ts          # API client setup
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── marketApi.ts       # API service layer
β”‚   β”œβ”€β”€ hooks/                 # React hooks
β”‚   β”‚   └── useMarketApi.ts
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ProductSearch.tsx
β”‚   β”‚   β”œβ”€β”€ MarketChat.tsx
β”‚   β”‚   └── LineDetails.tsx
β”‚   └── types/
β”‚       └── api.ts             # TypeScript types
β”œβ”€β”€ .env                       # Environment variables
└── package.json

πŸ“„ See: FRONTEND_INTEGRATION_GUIDE.md for complete setup instructions


πŸ” Finding What You Need

By Framework

React Developers:

  • Setup: FRONTEND_INTEGRATION_GUIDE.md β†’ React Integration
  • Hooks: FRONTEND_INTEGRATION_GUIDE.md β†’ Custom React Hooks
  • Components: FRONTEND_INTEGRATION_GUIDE.md β†’ React Components

Vue.js Developers:

  • Setup: FRONTEND_INTEGRATION_GUIDE.md β†’ Vue.js Integration
  • Composables: FRONTEND_INTEGRATION_GUIDE.md β†’ Composables

Vanilla JS Developers:

  • Examples: FRONTEND_INTEGRATION_GUIDE.md β†’ Vanilla JavaScript
  • Quick snippets: API_QUICK_REFERENCE.md

By Task

Setting Up:

  1. FRONTEND_INTEGRATION_GUIDE.md β†’ Setup
  2. FRONTEND_INTEGRATION_GUIDE.md β†’ API Client Setup

Building Features:

  1. API_QUICK_REFERENCE.md β†’ TypeScript Types
  2. FRONTEND_INTEGRATION_GUIDE.md β†’ Components
  3. API_DOCUMENTATION.md β†’ Endpoint Details

Debugging:

  1. API_DOCUMENTATION.md β†’ Error Handling
  2. API_QUICK_REFERENCE.md β†’ Common Pitfalls
  3. Postman Collection β†’ Test endpoints manually

πŸ“ž Support & Resources

Documentation

Interactive Tools

Getting Help

  1. Check the documentation files above
  2. Test with Postman collection
  3. Review code examples in integration guide
  4. Contact the backend team

πŸŽ“ Learning Path

Beginner

  1. βœ… Read API_QUICK_REFERENCE.md
  2. βœ… Import and test Postman collection
  3. βœ… Try basic fetch examples from Quick Reference
  4. βœ… Build a simple search component

Intermediate

  1. βœ… Set up API client from Integration Guide
  2. βœ… Create custom hooks/composables
  3. βœ… Implement error handling
  4. βœ… Add loading states

Advanced

  1. βœ… Implement caching strategy
  2. βœ… Add request debouncing
  3. βœ… Handle file uploads (voice/image)
  4. βœ… Optimize performance

πŸ“Š API Statistics

  • Total Endpoints: 7
  • JSON Endpoints: 5
  • File Upload Endpoints: 2
  • Authentication Required: None
  • Rate Limiting: None (currently)

πŸ”„ Version Information

  • API Version: 1.0.0
  • Documentation Version: 1.0.0
  • Last Updated: 2025-11-28

πŸ“ Quick Reference Card

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MarketWay Navigator API - Quick Reference                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Base URL: http://127.0.0.1:8000                            β”‚
β”‚ Docs: http://127.0.0.1:8000/docs                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ POST   /ask                  Ask questions                 β”‚
β”‚ GET    /product/search?q=    Search products               β”‚
β”‚ GET    /line/info/{name}     Get line details              β”‚
β”‚ GET    /history              Get market history            β”‚
β”‚ POST   /voice/query          Voice interaction             β”‚
β”‚ POST   /image/identify       Image recognition             β”‚
β”‚ GET    /navigate?line_name=  Get directions                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸŽ‰ Ready to Build!

You now have everything you need to integrate the MarketWay Navigator API into your frontend application. Choose your framework, follow the integration guide, and start building amazing features!

Happy Coding! πŸš€