const apisManagementController = new ApisManagementController(client);
ApisManagementController
- Import API Via File
- Import API Via URL
- Import New API Version Via File
- Import New API Version Via URL
- Inplace API Import Via File
- Inplace API Import Via URL
- Fetch API Entity
- Download API Specification
Import an API into the APIMatic Dashboard by uploading the API specification file.
You can also specify API Metadata while importing the API using this endpoint. When specifying Metadata, the uploaded file will be a zip file containing the API specification file and the APIMATIC-META
json file.
async importAPIViaFile(
file: FileWrapper,
requestOptions?: RequestOptions
): Promise<ApiResponse<ApiEntity>>
Parameter | Type | Tags | Description |
---|---|---|---|
file |
FileWrapper |
Form, Required | The API specification file. The type of the specification file should be any of the supported formats. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const file = new FileWrapper(fs.createReadStream('dummy_file'));
try {
const { result, ...httpResponse } = await apisManagementController.importAPIViaFile(file);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
400 | Bad Request | ApiError |
412 | Precondition Failed | ApiError |
422 | Unprocessable Entity | ApiError |
500 | Internal Server Error | ApiError |
Import an API into the APIMatic Dashboard by providing the URL of the API specification file.
You can also specify API Metadata while importing the API using this endpoint. When specifying Metadata, the URL provided will be that of a zip file containing the API specification file and the APIMATIC-META
json file.
async importAPIViaURL(
body: ImportApiViaUrlRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<ApiEntity>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
ImportApiViaUrlRequest |
Body, Required | Request Body |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const body: ImportApiViaUrlRequest = {
url: 'https://petstore.swagger.io/v2/swagger.json',
};
try {
const { result, ...httpResponse } = await apisManagementController.importAPIViaURL(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
400 | Bad Request | ApiError |
412 | Precondition Failed | ApiError |
422 | Unprocessable Entity | ApiError |
500 | Internal Server Error | ApiError |
Import a new version for an API, against an existing API Group, by uploading the API specification file.
You can also specify API Metadata while importing the API version using this endpoint. When specifying Metadata, the uploaded file will be a zip file containing the API specification file and the APIMATIC-META
json file.
async importNewAPIVersionViaFile(
apiGroupId: string,
accept: Accept,
versionOverride: string,
file: FileWrapper,
requestOptions?: RequestOptions
): Promise<ApiResponse<ApiEntity>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiGroupId |
string |
Template, Required | The ID of the API Group for which to import a new API version. |
accept |
Accept |
Header, Required | - |
versionOverride |
string |
Form, Required | The version number with which the new API version will be imported. This version number will override the version specified in the API specification file. APIMatic recommends versioning the API with the versioning scheme documented in the docs. |
file |
FileWrapper |
Form, Required | The API specification file. The type of the specification file should be any of the supported formats. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const apiGroupId = 'api_group_id6';
const accept = 'application/json';
const contentType = null;
const versionOverride = 'version_override2';
const file = new FileWrapper(fs.createReadStream('dummy_file'));
try {
const { result, ...httpResponse } = await apisManagementController.importNewAPIVersionViaFile(apiGroupId, accept, versionOverride, file);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Import a new version for an API, against an existing API Group, by providing the URL of the API specification file.
You can also specify API Metadata while importing the API version using this endpoint. When specifying Metadata, the URL provided will be that of a zip file containing the API specification file and the APIMATIC-META
json file.
async importNewAPIVersionViaURL(
apiGroupId: string,
accept: Accept,
body: ImportApiVersionViaUrlRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<ApiEntity>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiGroupId |
string |
Template, Required | The ID of the API Group for which to import a new API version. |
accept |
Accept |
Header, Required | - |
body |
ImportApiVersionViaUrlRequest |
Body, Required | Request Body |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const apiGroupId = '5c9de181dc6209221416f250';
const accept = 'application/json';
const contentType = null;
const body: ImportApiVersionViaUrlRequest = {
versionOverride: '1.2.3',
url: 'https://petstore.swagger.io/v2/swagger.json',
};
try {
const { result, ...httpResponse } = await apisManagementController.importNewAPIVersionViaURL(apiGroupId, accept, body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Replace an API version of an API Group, by uploading the API specification file that will replace the current version.
You can also specify API Metadata while importing the API version using this endpoint. When specifying Metadata, the uploaded file will be a zip file containing the API specification file and the APIMATIC-META
json file.
async inplaceAPIImportViaFile(
apiEntityId: string,
accept: Accept2,
file: FileWrapper,
requestOptions?: RequestOptions
): Promise<ApiResponse<void>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiEntityId |
string |
Template, Required | The ID of the API Entity to replace. |
accept |
Accept2 |
Header, Required | - |
file |
FileWrapper |
Form, Required | The API specification file. The type of the specification file should be any of the supported formats. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
void
const apiEntityId = 'api_entity_id4';
const accept = 'application/vnd.apimatic.apiEntity.full.v1+json';
const contentType = null;
const file = new FileWrapper(fs.createReadStream('dummy_file'));
try {
const { result, ...httpResponse } = await apisManagementController.inplaceAPIImportViaFile(apiEntityId, accept, file);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Replace an API version of an API Group, by providing the URL of the API specification file that will replace the current version.
You can also specify API Metadata while importing the API version using this endpoint. When specifying Metadata, the URL provided will be that of a zip file containing the API specification file and the APIMATIC-META
json file.
async inplaceAPIImportViaURL(
apiEntityId: string,
body: InplaceImportApiViaUrlRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<void>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiEntityId |
string |
Template, Required | The ID of the API Entity to replace. |
body |
InplaceImportApiViaUrlRequest |
Body, Required | Request Body |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
void
const apiEntityId = 'api_entity_id4';
const contentType = null;
const body: InplaceImportApiViaUrlRequest = {
url: 'https://petstore.swagger.io/v2/swagger.json',
};
try {
const { result, ...httpResponse } = await apisManagementController.inplaceAPIImportViaURL(apiEntityId, body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Fetch an API Entity.
async fetchAPIEntity(
apiEntityId: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<ApiEntity>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiEntityId |
string |
Template, Required | The ID of the API Entity to fetch. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const apiEntityId = 'api_entity_id4';
try {
const { result, ...httpResponse } = await apisManagementController.fetchAPIEntity(apiEntityId);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Download the API Specification file for a an API Version in any of the API Specification formats supported by APIMatic.
async downloadAPISpecification(
apiEntityId: string,
format: ExportFormats,
requestOptions?: RequestOptions
): Promise<ApiResponse<NodeJS.ReadableStream | Blob>>
Parameter | Type | Tags | Description |
---|---|---|---|
apiEntityId |
string |
Template, Required | The ID of the API Entity to download. |
format |
ExportFormats |
Query, Required | The format in which to download the API. The format can be any of the supported formats. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
NodeJS.ReadableStream | Blob
const apiEntityId = 'api_entity_id4';
const format = 'APIMATIC';
try {
const { result, ...httpResponse } = await apisManagementController.downloadAPISpecification(apiEntityId, format);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}