Platform Manager REST Client
Generate API client
This guide describes the process of generating an API client to access the VC Platform API from your custom application.
!!! note
Platform Manager REST Client offers generated REST API methods that make it easy to interact with the existing VirtoCommerce Platform API.
Prerequisites
- .NET Core 6.0, particularly if you are using MacOS or Linux.
Generate TypeScript API clients
To enable TypeScript API client generation in your project:
- Add dependencies to your project:
Using command
yarn add @vc-shell/api-client-generator cross-env
cross-env
runs scripts that set and use environment variables across platforms.
Manually
Add the dependencies to your project's package.json:
{
...
"devDependencies": {
...
"@vc-shell/api-client-generator": "latest",
"cross-env": "latest",
...
}
}
-
Configure client generation in your project. Inside your project's package.json file, add a "generate-api-client"
command to the list of scripts:
{
"scripts": {
...
"generate-api-client": cross-env api-client-generator --APP_PLATFORM_MODULES='[MarketplaceVendor,Catalog,Orders]' --APP_API_CLIENT_DIRECTORY=./src/api_client/
}
}
The options are listed in the table below:
Options | Description | Example |
---|
--APP_PLATFORM_MODULES | Platform modules to generate API client. {==string[]==} Customize the --APP_PLATFORM_MODULES list to match your project's requirements. | --APP_PLATFORM_MODULES='[MarketplaceVendor,Orders,Catalog]' |
--APP_API_CLIENT_DIRECTORY | Output directory for generated API clients. {==string==} | --APP_API_CLIENT_DIRECTORY=./src/api_client/ |
--APP_PLATFORM_URL | Platform URL to obtain client API configs. {==string==} | --APP_PLATFORM_URL=https://vcmp-dev.govirto.com/ |
--APP_PACKAGE_NAME | Package name for generated API clients. {==string==} | --APP_PACKAGE_NAME=vc-app-extend |
--APP_PACKAGE_VERSION | Package version for generated API clients. {==string==} | --APP_PACKAGE_VERSION=1.0.0 |
--APP_OUT_DIR | Output directory for generated API clients. {==string==} | --APP_OUT_DIR=./src/api_client/ |
--SKIP_BUILD | Skip build step. {==boolean==} | --SKIP_BUILD=true |
-
Configure Platform URL to ensure your project can access the platform's API configurations. Add the platform URL to your project's .env file:
APP_PLATFORM_URL=https://vcmp-dev.govirto.com/
!!! note
Alternatively, you can specify the Platform URL as a command option in the previous step when running the "generate-api-client"
command.
-
Generate the API clients using the following command:
yarn generate-api-client
This command generates the required API clients for your custom application. Now you can effortlessly access the VC Platform API from your custom application using the generated API client.