|
| 1 | +--- |
| 2 | +title: Discover APIs - VS Code extension |
| 3 | +description: API developers can use the Azure API Center extension for Visual Studio Code to discover APIs in their organization's API center. |
| 4 | +author: dlepow |
| 5 | +ms.service: azure-api-center |
| 6 | +ms.topic: how-to |
| 7 | +ms.date: 10/16/2024 |
| 8 | +ms.author: danlep |
| 9 | +ms.custom: |
| 10 | +# Customer intent: As an API developer, I want to use my Visual Studio Code environment to discover and consume APIs in my organizations API center. |
| 11 | +--- |
| 12 | + |
| 13 | +# Discover and consume APIs with the Azure API Center extension for Visual Studio Code |
| 14 | + |
| 15 | +API developers in your organization can discover and consume APIs in your [API center](overview.md) by using the Azure API Center extension for Visual Studio Code. The extension provides the following features: |
| 16 | + |
| 17 | +* **Discover APIs** - Browse the APIs in your API center, and view their details and documentation. |
| 18 | + |
| 19 | +* **Consume APIs** - Generate API SDK clients in their favorite language including JavaScript, TypeScript, .NET, Python, and Java, using the Microsoft Kiota engine that generates SDKs for Microsoft Graph, GitHub, and more. |
| 20 | + |
| 21 | +API developers can also take advantage of features in the extension to [register APIs](build-register-apis-vscode-extension.md) in the API center and ensure [API governance](govern-apis-vscode-extension.md). |
| 22 | + |
| 23 | +> [!TIP] |
| 24 | +> If you want enterprise app developers to discover APIs in a centralized location, optionally enable a [platform API catalog](enable-platform-api-catalog-vscode-extension.md) for your API center in Visual Studio Code. The platform API catalog is a read-only view of the API inventory. |
| 25 | +
|
| 26 | +[!INCLUDE [vscode-extension-basic-prerequisites](includes/vscode-extension-basic-prerequisites.md)] |
| 27 | + |
| 28 | +* [REST client extension](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) - to send HTTP requests and view the responses in Visual Studio Code directly |
| 29 | +* [Microsoft Kiota extension](https://marketplace.visualstudio.com/items?itemName=ms-graph.kiota) - to generate API clients |
| 30 | + |
| 31 | +[!INCLUDE [vscode-extension-setup](includes/vscode-extension-setup.md)] |
| 32 | + |
| 33 | +## Discover APIs |
| 34 | + |
| 35 | +API center resources appear in the tree view on the left-hand side. Expand an API center resource to see APIs, versions, definitions, environments, and deployments. |
| 36 | + |
| 37 | +:::image type="content" source="media/discover-apis-vscode-extension/explore-api-centers.png" alt-text="Screenshot of API Center tree view in Visual Studio Code." lightbox="media/discover-apis-vscode-extension/explore-api-centers.png"::: |
| 38 | + |
| 39 | +Search for APIs within an API Center by using the search icon shown in the **Apis** tree view item. |
| 40 | + |
| 41 | +## View API documentation |
| 42 | + |
| 43 | +You can view the documentation for an API definition in your API center and try API operations. This feature is only available for OpenAPI-based APIs in your API center. |
| 44 | + |
| 45 | +1. Expand the API Center tree view to show an API definition. |
| 46 | +1. Right-click on the definition, and select **Open API Documentation**. A new tab appears with the Swagger UI for the API definition. |
| 47 | + |
| 48 | + :::image type="content" source="media/discover-apis-vscode-extension/view-api-documentation.png" alt-text="Screenshot of API documentation in Visual Studio Code." lightbox="media/discover-apis-vscode-extension/view-api-documentation.png"::: |
| 49 | + |
| 50 | +1. To try the API, select an endpoint, select **Try it out**, enter required parameters, and select **Execute**. |
| 51 | + |
| 52 | + > [!NOTE] |
| 53 | + > Depending on the API, you might need to provide authorization credentials or an API key to try the API. |
| 54 | +
|
| 55 | + > [!TIP] |
| 56 | + > Using the pre-release version of the extension, you can generate API documentation in Markdown, a format that's easy to maintain and share with end users. Right-click on the definition, and select **Generate Markdown**. |
| 57 | +
|
| 58 | +## Generate HTTP file |
| 59 | + |
| 60 | +You can view a `.http` file based on the API definition in your API center. If the REST Client extension is installed, you can make requests directory from the Visual Studio Code editor. This feature is only available for OpenAPI-based APIs in your API center. |
| 61 | + |
| 62 | +1. Expand the API Center tree view to show an API definition. |
| 63 | +1. Right-click on the definition, and select **Generate HTTP File**. A new tab appears that renders a .http document populated by the API specification. |
| 64 | + |
| 65 | + :::image type="content" source="media/discover-apis-vscode-extension/generate-http-file.png" alt-text="Screenshot of generating a .http file in Visual Studio Code." lightbox="media/discover-apis-vscode-extension/generate-http-file.png"::: |
| 66 | + |
| 67 | +1. To make a request, select an endpoint, and select **Send Request**. |
| 68 | + |
| 69 | + > [!NOTE] |
| 70 | + > Depending on the API, you might need to provide authorization credentials or an API key to make the request. |
| 71 | +
|
| 72 | +## Generate API client |
| 73 | + |
| 74 | +Use the Microsoft Kiota extension to generate an API client for your favorite language. This feature is only available for OpenAPI-based APIs in your API center. |
| 75 | + |
| 76 | +1. Expand the API Center tree view to show an API definition. |
| 77 | +1. Right-click on the definition, and select **Generate API Client**. The **Kiota OpenAPI Generator** pane appears. |
| 78 | +1. Select the API endpoints and HTTP operations you wish to include in your SDKs. |
| 79 | +1. Select **Generate API client**. |
| 80 | + 1. Enter configuration details about the SDK name, namespace, and output directory. |
| 81 | + 1. Select the language for the generated SDK. |
| 82 | + |
| 83 | + :::image type="content" source="media/discover-apis-vscode-extension/generate-api-client.png" alt-text="Screenshot of Kiota OpenAPI Explorer in Visual Studio Code." lightbox="media/discover-apis-vscode-extension/generate-api-client.png"::: |
| 84 | + |
| 85 | +The client is generated. |
| 86 | + |
| 87 | +For details on using the Kiota extension, see [Microsoft Kiota extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-graph.kiota). |
| 88 | + |
| 89 | +## Export API specification |
| 90 | + |
| 91 | +You can export an API specification from a definition and then download it as a file. |
| 92 | + |
| 93 | +To export a specification in the extension's tree view: |
| 94 | + |
| 95 | +1. Expand the API Center tree view to show an API definition. |
| 96 | +1. Right-click on the definition, and select **Export API Specification Document**. A new tab appears that renders an API specification document. |
| 97 | + |
| 98 | + :::image type="content" source="media/discover-apis-vscode-extension/export-specification.png" alt-text="Screenshot of exporting API specification in Visual Studio Code." lightbox="media/discover-apis-vscode-extension/export-specification.png"::: |
| 99 | + |
| 100 | +You can also export a specification using the Command Palette: |
| 101 | + |
| 102 | +1. Type the **Ctrl+Shift+P** keyboard shortcut to open the Command Palette. |
| 103 | +1. Select **Azure API Center: Export API Specification Document**. |
| 104 | +1. Make selections to navigate to an API definition. A new tab appears that renders an API specification document. |
| 105 | + |
| 106 | +## Related content |
| 107 | + |
| 108 | +* [Azure API Center - key concepts](key-concepts.md) |
| 109 | +* [Build and register APIs with the Azure API Center extension for Visual Studio Code](build-register-apis-vscode-extension.md) |
| 110 | +* [Govern APIs with the Azure API Center extension for Visual Studio Code](govern-apis-vscode-extension.md) |
| 111 | +* [Enable and view platform API catalog in Visual Studio Code](enable-platform-api-catalog-vscode-extension.md) |
| 112 | + |
0 commit comments