{
  "openapi": "3.0.3",
  "info": {
    "title": "ChinaKit — Official Public REST & MCP API",
    "version": "1.0.0",
    "description": "ChinaKit exposes deterministic China travel, visa-free transit (240h TWOV), customs medication legality, work permit points, expatriate Individual Income Tax (IIT), Hague Apostille workflows, CAAC powerbank limits, and city readiness data via MCP and REST.",
    "contact": {
      "name": "ChinaKit",
      "url": "https://chinakit.io",
      "email": "admin@chinakit.io"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "externalDocs": {
    "description": "ChinaKit Official Portal",
    "url": "https://chinakit.io"
  },
  "servers": [
    {
      "url": "https://chinakit.io",
      "description": "Production Edge & Cloud Run"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/api/v1/me": {
      "get": {
        "operationId": "verifyApiConnection",
        "summary": "Verify ChinaKit API Key & Service Health",
        "description": "Authentication check and metadata endpoint for Albato, RapidAPI, Make, and developer integrations.",
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "Authenticated connection status and tool count"
          }
        }
      }
    },
    "/api/v1/tools/calculate_china_work_permit_points": {
      "post": {
        "operationId": "calculate_china_work_permit_points",
        "summary": "China Z-Visa Work Permit Category A/B/C Points & Exemption Calculator",
        "description": "Score an applicant under the China SAFIEA work permit rubric (Category A >=85, Category B >=60, Category C <60), detect 6x local average wage or Top-100 PhD Category A exemptions, and prescribe lowest-cost point upgrades.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "age": {
                    "type": "integer",
                    "description": "Applicant chronological age in years (18-45 earns maximum 15 points).",
                    "default": 30
                  },
                  "education": {
                    "type": "string",
                    "enum": [
                      "phd",
                      "master",
                      "bachelor",
                      "diploma_or_less"
                    ],
                    "description": "Highest academic degree awarded: phd, master, bachelor, or diploma_or_less.",
                    "default": "bachelor"
                  },
                  "topUniversityGrad": {
                    "type": "boolean",
                    "description": "Whether the degree is from a QS, THE, or ARWU Global Top-100 university (+5 bonus or PhD Category A bypass).",
                    "default": false
                  },
                  "workExperienceYears": {
                    "type": "number",
                    "description": "Total post-graduation full-time relevant employment years.",
                    "default": 3
                  },
                  "monthlySalaryRMB": {
                    "type": "number",
                    "description": "Contracted gross monthly base compensation in Chinese Yuan (RMB).",
                    "default": 25000
                  },
                  "cityTier": {
                    "type": "string",
                    "enum": [
                      "tier1_super",
                      "tier1",
                      "tier2",
                      "other"
                    ],
                    "description": "Employment city tier for local wage multiple benchmarking (tier1_super: Beijing/Shanghai; tier1: Shenzhen/Guangzhou/Hangzhou; tier2; other).",
                    "default": "tier1_super"
                  },
                  "hskLevel": {
                    "type": "string",
                    "enum": [
                      "none",
                      "hsk1_2",
                      "hsk3",
                      "hsk4",
                      "hsk5",
                      "hsk6"
                    ],
                    "description": "Certified HSK Mandarin proficiency test level (none up to hsk6).",
                    "default": "none"
                  },
                  "workLocationType": {
                    "type": "string",
                    "enum": [
                      "encouraged_region",
                      "standard",
                      "remote_western"
                    ],
                    "description": "Regional policy zone: standard, encouraged_region, or remote_western (+5 to +10 pts).",
                    "default": "standard"
                  },
                  "localFtzIncentive": {
                    "type": "boolean",
                    "description": "Whether the employer entity operates in a Free Trade Zone or National Hi-Tech Park (+5 municipal points).",
                    "default": false
                  },
                  "emergencyDemandSector": {
                    "type": "boolean",
                    "description": "Whether the role falls under regional AI, Semiconductor, Biotech, or Green Tech shortage talent catalogs (+10 pts).",
                    "default": false
                  },
                  "fortune500Executive": {
                    "type": "boolean",
                    "description": "Whether the applicant holds a Fortune Global 500 senior executive or technical specialist appointment.",
                    "default": false
                  },
                  "annualSalaryExceed6xAverage": {
                    "type": "boolean",
                    "description": "Manual override flag confirming contracted annual pay reaches 6x municipal average wage for automatic Category A exemption.",
                    "default": false
                  },
                  "internationalAwardWinner": {
                    "type": "boolean",
                    "description": "Whether the applicant holds a globally recognized scientific or industrial achievement award.",
                    "default": false
                  }
                },
                "required": [
                  "age",
                  "education",
                  "workExperienceYears",
                  "monthlySalaryRMB"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/check_china_customs_medication_legality": {
      "post": {
        "operationId": "check_china_customs_medication_legality",
        "summary": "China Border Narcotic & Psychotropic Prescription Compliance Screener",
        "description": "Screen personal prescription drugs and over-the-counter remedies by English brand, generic ingredient, or Chinese alias against China Customs Class I/II psychotropic controls, carrying-day caps, and Red Channel paperwork checklists.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "medicationQuery": {
                    "type": "string",
                    "description": "Generic ingredient, US/EU brand name, or Chinese medicine name (e.g. \"Adderall\", \"Zolpidem\", \"Ritalin\", \"ibuprofen\")."
                  },
                  "categoryFilter": {
                    "type": "string",
                    "enum": [
                      "all",
                      "psychotropic_1",
                      "psychotropic_2",
                      "narcotic",
                      "prescription",
                      "otc_allowed"
                    ],
                    "description": "Optional control category filter to narrow matches (all, psychotropic_1, psychotropic_2, narcotic, prescription, otc_allowed).",
                    "default": "all"
                  }
                },
                "required": [
                  "medicationQuery"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/calculate_china_expat_iit_and_bonus": {
      "post": {
        "operationId": "calculate_china_expat_iit_and_bonus",
        "summary": "Expatriate China Individual Income Tax (IIT) & Tax-Exempt Fringe Optimizer",
        "description": "Simulate annual expatriate individual income tax liability in Mainland China comparing Seven Tax-Exempt Allowances (housing, schooling, home leave) against resident special deductions and standalone vs combined annual bonus taxation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "monthlyGrossSalary": {
                    "type": "number",
                    "description": "Contracted gross monthly cash salary before tax and allowances in RMB."
                  },
                  "annualBonusRMB": {
                    "type": "number",
                    "description": "One-off annual performance bonus in RMB evaluated under Caishui [2023] No. 30 standalone brackets.",
                    "default": 0
                  },
                  "bonusTaxTreatment": {
                    "type": "string",
                    "enum": [
                      "preferential_standalone",
                      "combined_comprehensive",
                      "auto_optimal"
                    ],
                    "description": "Taxation treatment for annual bonus: preferential_standalone, combined_comprehensive, or auto_optimal.",
                    "default": "preferential_standalone"
                  },
                  "citySocialSecurityScheme": {
                    "type": "string",
                    "enum": [
                      "NONE",
                      "SHANGHAI",
                      "BEIJING",
                      "SHENZHEN"
                    ],
                    "description": "Municipal expatriate social insurance contribution baseline: NONE, SHANGHAI, BEIJING, or SHENZHEN.",
                    "default": "SHANGHAI"
                  },
                  "isChinaTaxResident": {
                    "type": "boolean",
                    "description": "Whether the expatriate stays >= 183 cumulative days in the tax year (residency & 6-year rule check).",
                    "default": true
                  },
                  "monthsInChina": {
                    "type": "integer",
                    "description": "Number of salaried employment months worked in China during the tax year (1 to 12).",
                    "default": 12
                  },
                  "housingAllowance": {
                    "type": "number",
                    "description": "Monthly tax-exempt housing reimbursement supported by VAT fapiao in RMB.",
                    "default": 0
                  },
                  "childrenEducationAllowance": {
                    "type": "number",
                    "description": "Monthly international school tuition reimbursement in RMB.",
                    "default": 0
                  },
                  "languageTrainingAllowance": {
                    "type": "number",
                    "description": "Monthly Mandarin language training reimbursement in RMB.",
                    "default": 0
                  },
                  "mealLaundryAllowance": {
                    "type": "number",
                    "description": "Monthly meal and laundry non-taxable allowance in RMB.",
                    "default": 0
                  },
                  "homeLeaveAllowance": {
                    "type": "number",
                    "description": "Monthly amortized home-leave airfare allowance in RMB.",
                    "default": 0
                  },
                  "applyFringeBenefitsExemption": {
                    "type": "boolean",
                    "description": "Enable the Eight/Seven Expatriate Tax-Exempt Fringe Benefits regime (true) vs resident itemized deductions.",
                    "default": true
                  }
                },
                "required": [
                  "monthlyGrossSalary"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/validate_china_transit_and_visa_free_entry": {
      "post": {
        "operationId": "validate_china_transit_and_visa_free_entry",
        "summary": "Mainland China Visa-Free Entry, TWOV Routing & Midnight Clock Evaluator",
        "description": "Inspect unilateral 15/30-day visa-waiver eligibility or 54-nation Transit Without Visa (TWOV) admissibility, verify A-B-C third-region flight compliance, detect domestic multi-stop disqualifications, and generate IATA Timatic directives.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nationality": {
                    "type": "string",
                    "description": "Traveler passport nationality as ISO-3 code or English name (e.g. \"USA\", \"FRA\", \"GBR\", \"AUS\")."
                  },
                  "originCountry": {
                    "type": "string",
                    "description": "Country or SAR of last flight embarkation immediately prior to Mainland China arrival (e.g. \"USA\", \"KOR\", \"HKG\")."
                  },
                  "transitPortCode": {
                    "type": "string",
                    "description": "Designated Chinese entry port IATA/cluster code (e.g. \"PVG\", \"PEK\", \"CAN\", \"TFU\", \"XIY\").",
                    "default": "PVG"
                  },
                  "destinationCountry": {
                    "type": "string",
                    "description": "Country or SAR of immediate onward departure after China (e.g. \"HKG\", \"JPN\", \"MAC\", \"TWN\")."
                  },
                  "intendedStayHours": {
                    "type": "integer",
                    "description": "Planned duration in Mainland China measured in hours.",
                    "default": 72
                  },
                  "hasConfirmedConnectingTicket": {
                    "type": "boolean",
                    "description": "Whether the passenger already holds a confirmed seat and date onward ticket departing to Country C.",
                    "default": true
                  },
                  "travelWithinAllowedRegion": {
                    "type": "boolean",
                    "description": "Whether the stay remains inside the permitted provincial port cluster boundaries.",
                    "default": true
                  },
                  "hasMultipleDomesticLayovers": {
                    "type": "boolean",
                    "description": "True if the itinerary includes another domestic China stopover across a different port cluster.",
                    "default": false
                  },
                  "arrivalDateTime": {
                    "type": "string",
                    "description": "Optional ISO arrival timestamp (e.g. \"2026-11-20T14:30\") to calculate next-day midnight deadline."
                  }
                },
                "required": [
                  "nationality",
                  "originCountry",
                  "destinationCountry"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/query_china_document_apostille_steps": {
      "post": {
        "operationId": "query_china_document_apostille_steps",
        "summary": "Hague Apostille & Consular Legalization Document Workflow Advisor",
        "description": "Retrieve country-specific legalization workflows for background checks, diplomas, TEFL, and marriage certificates used in China visa filings, flagging federal-vs-state Apostille rejection traps and expected processing lead times.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "countryIso": {
                    "type": "string",
                    "description": "Issuing country ISO-3 code or name where the document was notarized/issued (e.g. \"USA\", \"GBR\", \"CAN\", \"AUS\", \"DEU\", \"FRA\", \"ARE\")."
                  },
                  "docTypeId": {
                    "type": "string",
                    "enum": [
                      "criminal_record",
                      "degree_diploma",
                      "tefl_tesol",
                      "marriage_cert",
                      "medical_exam",
                      "power_of_attorney"
                    ],
                    "description": "Target certificate type requiring China recognition: criminal_record, degree_diploma, tefl_tesol, marriage_cert, medical_exam, or power_of_attorney."
                  }
                },
                "required": [
                  "countryIso",
                  "docTypeId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/recommend_china_essential_apps_and_payment": {
      "post": {
        "operationId": "recommend_china_essential_apps_and_payment",
        "summary": "Foreigner China Mobile App Setup, Passport KYC & Wallet Binding Guide",
        "description": "Search curated step-by-step setup guides for Alipay, WeChat Pay, Didi, 12306 rail booking, Amap navigation, and eSIM apps using foreign passports and overseas Visa/Mastercard cards without Chinese bank accounts.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "appSlugOrQuery": {
                    "type": "string",
                    "description": "App identifier or keyword such as \"alipay\", \"wechat\", \"didi\", \"12306\", \"esim\", \"meituan\", or \"maps\".",
                    "default": ""
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "all",
                      "payment",
                      "connectivity",
                      "transport",
                      "lifestyle"
                    ],
                    "description": "Filter app playbooks by functional category: all, payment, connectivity, transport, or lifestyle.",
                    "default": "all"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/lookup_china_destination_foreigner_guide": {
      "post": {
        "operationId": "lookup_china_destination_foreigner_guide",
        "summary": "Chinese City & Attraction Passport Ticketing, Transit Zone & Card Readiness Index",
        "description": "Query verified attraction entry requirements across China cities (Beijing, Shanghai, Chengdu, Macau, etc.), returning turnstile passport scanning rules, foreign card acceptance, subway exits, and 144/240h transit compatibility.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cityOrAttraction": {
                    "type": "string",
                    "description": "Chinese city, SAR, province, or landmark name/slug (e.g. \"Beijing\", \"Shanghai\", \"798 Art Zone\", \"Macau\", \"Chengdu\")."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Maximum matching destination records to return (between 1 and 10).",
                    "default": 3
                  }
                },
                "required": [
                  "cityOrAttraction"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    },
    "/api/v1/tools/calculate_caac_powerbank_and_alipay_split": {
      "post": {
        "operationId": "calculate_caac_powerbank_and_alipay_split",
        "summary": "CAAC Cabin Lithium Watt-Hour Gate & ¥200 Alipay Fee-Waiver Splitter",
        "description": "Compute lithium battery watt-hours (mAh * V / 1000) against Civil Aviation Administration of China 100Wh/160Wh carry-on prohibitions AND split any RMB merchant bill into <=¥200 chunks to waive the 3% foreign credit card surcharge.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "capacityMah": {
                    "type": "number",
                    "description": "Power bank printed battery capacity rating in milliampere-hours (mAh, e.g. 10000, 20000, 27000, 50000).",
                    "default": 20000
                  },
                  "voltageV": {
                    "type": "number",
                    "description": "Rated nominal cell voltage in Volts (standard lithium-ion cells are 3.7V or 3.85V).",
                    "default": 3.7
                  },
                  "paymentAmountRmb": {
                    "type": "number",
                    "description": "Optional merchant invoice total in RMB to calculate optimal <=200 RMB split transactions saving 3% fee.",
                    "default": 0
                  }
                },
                "required": [
                  "capacityMah"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic tool execution result"
          }
        }
      }
    }
  }
}
