Skip to main content

APIMatic CLI Commands

APIMatic CLI provides support for the following features:


For complete documentation of the APIMatic CLI commands, please refer to the Command Line Reference.

Validate API

Before you start using APIMatic, its important to validate your API specification to ensure syntactic and semantic correctness. This will allow you to take full advantage of APIMatic’s code generation abilities. Use the following command to validate your API specification.

$ apimatic api:validate --file="./filename.json"

Fixing validation issues will ensure that APIMatic will ensure you have a smooth experience using APIMatic’s services. The validation output is categorized into three categories defined below:

  • Errors: Any syntax/semantic issues found in the API definition; for example, if a GET method contains a request body. API definition file import cannot proceed in case of an error. You will be required to fix the issues listed for your definition if that happens.
  • Warnings: Any unexpected behavior that may affect the output; for example, if the parameter example provided is invalid. Warnings will not halt API import, but it is recommended that you fix these issues so your API definition results in the best possible experience.
  • Messages: Recommendations or suggestions that can help enhance your API definition and its completeness. For example, messages can point out that an endpoint description or a parameter example is missing. Messages will not halt API import.

Transform API

APIMatic’s API Transformer is a powerful tool that allows interconversion between a large number of API specification formats including OpenAPI/Swagger, RAML, WSDL and Postman collections. This gives you the ability to use a whole array of format specific tools without having to port your API to a different specification format.

List of all the supported API specification formats are given in the API Transformer Docs.

In order to transform an API, use the apimatic api:transform command. You can provide the source directory where the API specification is stored, required specification format and destination directory to download the transformed file.

$ apimatic api:transform --format="OpenApi3Json" --file="filename.json" --destination="D:/destination"

Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json

Transform API via Url

Alternatively, you can also provide a link to the file using the --url option, if the file is stored in a publicly accessible location on the internet.

$ apimatic api:transform --format="RAML" --url=""  --destination="D:/destination"

Success! Your transformed file is located at D:/swagger_raml.yaml

To get a list of the available transformation formats, use the apimatic api:transform --help command.

$ apimatic api:transform --help
--format=format (required) specification format to transform API specification into

Generate SDK

APIMatic CLI also allows automatic SDK generation for your APIs in multiple popular languages including Java, C#/.NET, Python, Typescript, Ruby and PHP. Use the apimatic sdk:generate command to generate SDK for any sample API.

$ apimatic sdk:generate

The following example generates Python SDK for a sample API (filename.json) and downloads it to your working directory in the form of a .zip file.

$ apimatic sdk:generate --platform=python --file="filename.json" --zip

Generating SDK... done
Downloading SDK... done
Success! Your SDK is located at D:\

You can find the list of supported languages/platforms for SDK generation by invoking the apimatic sdk:generate --help command.

$ apimatic sdk:generate --help
--platform=platform (required) language platform for sdk

Generate API Documentation Portal

APIMatic’s auto-generated API Portal combines API documentation, SDKs and code samples into one neat static website. Embracing the philosophy of documentation as code, the API Portal can be generated right from the terminal, allowing the entire process to be made part of the release pipeline.

In order to generate an API Portal, the CLI expects inputs to be provided in a specific format. Details about the required input format are provided in the Generating API Portal Docs.

A sample input is provided in the GitHub repository. Clone or download this sample input. It consists of:

  • A content directory containing Markdown guides.
  • A spec directory containing API specifications.
  • A static directory containing images or any other static content referenced in the documentation.
  • A configuration file called APIMATIC-BUILD.json.

Use the apimatic portal:generate command to generate a static API Portal.

$ apimatic portal:generate --folder="./input-folder" --destination="D:/destination"

Downloading portal... done
Your portal has been generated at D:\generated_portal

The generated API Portal is downloaded at the location identified by the --destination flag. In order to preview the generated API Portal, you will need to upload the generated directory to a web server.