HS codes have been adopted by the majority of countries as being the basis for import and export inspection and the generation of trade statistics. Customs authorities and international traders need a HS code query tool to make their processing efficient and automatic. Since HS codes are identified at 5–7 levels of classification, then any intelligent coding service will need to combine a knowledge database, with the techniques of data mining, machine learning and semantics reasoning. In this paper, the authors propose a comprehensive solution for such a coding service. The architecture, related techniques, technical solution and implementation considerations for the proposed system have been provided. Several of the proposed functions and implementation techniques have been developed and deployed by the Shanghai International Airport Entry-Exit Inspection and Quarantine Bureau. The coding service has been published as a Web service, and has the potential to be widely used by authorities and international traders around the world. The proposed system may also be appropriate for other applications that relate to code or classification processes, such as RFID-based or product ontology based applications.