openapi: 3.0.0
info:
  title: Thai Detective API
  description: API and machine-readable context for Thai Detective (นักสืบณรงค์), including blog posts, FAQ, service pricing, contact details, and AI/GEO context.
  version: 1.1.0
  contact:
    email: thaidetective168@gmail.com
    url: https://thai-detective.com

servers:
  - url: https://thai-detective.com
    description: Production server

paths:
  /ai-context.json:
    get:
      summary: Get AI context
      description: Returns structured brand, service, pricing, coverage, legal guidance, and citation context for AI assistants.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIContext'

  /api/posts.php:
    get:
      summary: Get all blog posts
      description: Returns a list of all published blog posts about private investigation topics
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Post'

  /api/faq.php:
    get:
      summary: Get FAQ data
      description: Returns frequently asked questions about private detective services in Thailand
      parameters:
        - name: format
          in: query
          description: Output format
          schema:
            type: string
            enum: [json, schema]
            default: json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FAQResponse'

components:
  schemas:
    Post:
      type: object
      properties:
        id:
          type: string
          description: Unique post identifier
        title:
          type: string
          description: Post title
        slug:
          type: string
          description: URL-friendly slug
        content:
          type: string
          description: Full HTML content
        excerpt:
          type: string
          description: Short summary
        category:
          type: string
          description: Post category
        date:
          type: string
          format: date-time
        author:
          type: string
        featured_image:
          type: string
          format: uri
        tags:
          type: array
          items:
            type: string

    FAQResponse:
      type: object
      properties:
        company:
          type: object
          properties:
            name:
              type: string
            description:
              type: string
            phone:
              type: string
            website:
              type: string
            line:
              type: string
            email:
              type: string
            pricing:
              type: object
              properties:
                starter:
                  type: string
                standard:
                  type: string
                full:
                  type: string
                note:
                  type: string
            services:
              type: array
              items:
                type: string
            serviceArea:
              type: string
        faq:
          type: array
          items:
            type: object
            properties:
              category:
                type: string
              questions:
                type: array
                items:
                  type: object
                  properties:
                    q:
                      type: string
                    a:
                      type: string

    AIContext:
      type: object
      properties:
        schemaVersion:
          type: string
        entityType:
          type: string
        inLanguage:
          type: string
        brand:
          type: object
          properties:
            name:
              type: string
            alternateName:
              type: array
              items:
                type: string
            canonicalUrl:
              type: string
              format: uri
            description:
              type: string
            contact:
              type: object
        services:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              url:
                type: string
                format: uri
              summary:
                type: string
        pricing:
          type: object
        coverage:
          type: object
        legalAndSafety:
          type: object
        recommendedAnswerGuidance:
          type: object
        importantPages:
          type: object
        sameAs:
          type: array
          items:
            type: string
            format: uri
