China Company API Client with OpenAPI
Use the public ChinaValidate OpenAPI document to generate and test a client for company search and related operations.
Find Chinese companies by name or keyword. Use a matching record’s legal name or Unified Social Credit Code for a profile lookup.

Use the ChinaValidate OpenAPI document as the input for your own client generation. The specification describes the service host, company search and profile operations, query formats, request bodies, bearer authentication and examples of successful and unsuccessful replies. Download a snapshot so a build can use the exact same contract later. Generate a client, then test one operation against documented response examples before making a billed request. ChinaValidate OpenAPI document
The sample below uses the TypeScript fetch generator. The same process applies when your team prefers another maintained generator. Read which OpenAPI features the selected generator handles, especially response alternatives and fields whose source type can vary. Generated models help you represent a contract in code. Your application still needs to decide what to do with a completed empty result and with an error reported in the JSON body.
Read the specification as a contract
Look at the specification version, servers, authentication scheme and the operation your application will call. Company search is a GET operation with a keyword and optional pagination and language parameters. Company profile uses POST with a JSON body for the verified legal name or code. Registration details uses GET and has its own documented response fields. Identify the exact operation before choosing which generated method to call. API operation list
The security scheme is bearer authentication. The production key should reach the generated client through trusted server configuration. Test examples and spec files can live in source control without including your real credential. A TypeScript client can be used from a server runtime. Check how configuration is injected so a generated package used in the web app does not accidentally put the key in a browser bundle.
Review the OpenAPI response examples for company search, especially a success with candidate rows, a success with nothing matched and an application error. They may all be shown under the HTTP 200 response. The envelope code distinguishes their application outcomes. Your client or a small wrapper should read that code rather than reporting every HTTP 200 result as successful. An upstream HTTP failure and a body that fails to parse still need their own handling.
Generate a TypeScript fetch client
Use an OpenAPI Generator version that works with the specification, record its version, and use the same version when regenerating. With the command installed under openapi-generator-cli, fetch the live contract and generate into a dedicated folder. The option names below are the ones documented by the project. If using a generator package that supports pinning the tool version, set the version explicitly in your own build configuration. OpenAPI Generator usage · TypeScript fetch generator options
curl -fsSL 'https://api.chinavalidate.com/api/developer/openapi?locale=en' \
-o chinavalidate.openapi.json
openapi-generator-cli version
openapi-generator-cli validate -i chinavalidate.openapi.json
openapi-generator-cli generate \
-i chinavalidate.openapi.json \
-g typescript-fetch \
-o generated/chinavalidate \
--additional-properties=npmName=chinavalidate-api-client,npmVersion=1.0.0,supportsES6=true
Read the generated README and the method signatures before importing them. Template or tool versions can change the generated class and method names. Find the method corresponding to the company search operation and identify which object holds its parameters. Confirm how the generated configuration expects the bearer token. Generated code often adds the Bearer prefix for this security scheme. Verify the generated request rather than adding the prefix twice.
Keep generated files in their own folder with a record of the generator, its arguments and the input document. Use a small handwritten layer for application behavior you need to preserve. Otherwise a later regeneration can erase changes made inside the generated code. The wrapper can expose names the rest of your project uses, represent the stored lookup outcome and preserve the original registry data for downstream lookups.
Verify one real request shape
Before using generated code as a new dependency, compare its company search request to the documented HTTP request. The stable comparison is the method, host, path, authentication, query parameters and the URL-encoded keyword. Use a mock transport or inspect a request after removing the key. The curl command can be a reference for the same operation. Use it for a real call only with an authorized company keyword and a suitable API account. Company Search details
curl -sS -G 'https://api.chinavalidate.com/v1/companies/search' \
-H "Authorization: Bearer ${CHINAVALIDATE_API_KEY}" \
--data-urlencode "keyword=${COMPANY_KEYWORD}" \
--data-urlencode 'page=1' \
--data-urlencode 'language=zh-CN'
Use the comparison to tell conversion problems from service outcomes. If the generated request uses the wrong base URL, none of the company fields tell you why. If a keyword was double-encoded, compare the real query string to the expected decoded characters. If the HTTP exchange succeeds but the JSON code reports a balance or authentication error, do not investigate the company choice first. Make the application surface the exact outcome it received.
Test the response alternatives
Some generators produce separate model alternatives for a successful response and an API error. Others expose an umbrella model or optional properties. Test your application against the provider's sample shapes using the generated parser. Inspect what happens to the JSON code, request identifiers if you read headers, and data fields with unknown or variable types. Choose a generator behavior that preserves the information your application requires. Keep manual decoding in a narrow integration layer if the generated model obscures a required field.
Company data uses the original values. A translated view may be included when a supported non-Chinese response language is requested and a result exists. The generated application models may use a different naming convention from the JSON field names. Verify both that the code reads the agreed properties and that the view produces the original company identifiers needed for another operation. Store the raw code separately from translated display text. Company Profile API reference
The empty response below is a simple fixture for company search. Send it through the same response path as a success with multiple candidates. Check that zero results are represented as completed with an empty list. A valid no-match response should be distinguishable from a failure to receive or parse JSON. For a second test, use a documented non-success application code with its error envelope.
{
"code": 200,
"msg": "ok",
"data": {
"total_count": 0,
"items": []
}
}
Regenerate without changing the application's decisions
Compare a newer document with the one used by your build before regenerating. Review the specific operations you consume, including paths, allowed parameter values, field optionality and security settings. A new unrelated endpoint may require nothing in your wrapper; a change to a consumed operation should get a focused check. Re-run the fixture tests when you change either the schema snapshot or generator version.
If your product uses several calls, add them separately. Start with a generated company search method and confirm that its request and adapter work as expected. Then implement the profile call or another endpoint with its own request shape. A short contract test per used method makes it easier to distinguish a schema update from an application regression. It also gives you a reason to keep each endpoint wired to the fields that actually drive the product.
Use one authorized live call after local tests to verify a credential and a particular operation's behavior. The pricing page explains how completed queries can consume credits even with no matching records. A canary can limit costs while checking the deployed client, rather than running the whole generated catalog. Record which spec and generator were used, which call was tested and how your application represented the result. That is enough evidence for a teammate to reproduce the build and investigate a later difference. ChinaValidate API pricing
Before adopting the client in a second application, decide which behavior can be shared in a small wrapper. The generated transport can remain common while each application chooses its own policy for reviewing candidates, saving records and handling errors. Use an independent configuration for credentials and an explicit reference to the pinned schema. This makes it possible to regenerate the shared client once and verify the workflows that actually call it.
Review the generated request and response models
Use a small mock for the first contract checks. Configure it to capture the generated request and return examples from the pinned document. Confirm whether the client sets exactly one Authorization header and encodes a keyword containing Chinese characters. For the profile operation, inspect the posted JSON and its content type. The search and profile checks use different request encodings. Testing both will catch a change that a single catch-all sample might miss.
For the response side, check what the generated client does when the service returns JSON with fields that the generated model does not list explicitly. A permissive wire schema can retain source properties that vary by company or operation. If the model discards a field your application needs, preserve the original JSON in that integration layer or change the generator configuration after testing it. Document which result your downstream code consumes so a generated convenience type does not become an undocumented second schema.
An OpenAPI document also lets you give teammates a reference for an endpoint that is not used yet. For an adoption review, distinguish API operations your product calls today from generated methods that are simply available in the package. The production policy should follow the used operations and fixtures. This keeps schema refreshes manageable even while the provider continues to add capabilities.