Using OpenAPI Specs

Published on March 16th, 2021


The Open API spec support of Backstage allows users to look up and read the OpenAPI specs of services in the catalog.

Creating Open API specs is outside the scope of this documentation. Please see the Swagger OpenAPI Getting Started Guide for more information on writing OpenAPI specs.


Before starting this guide, please…

  1. Prepare an OpenAPI spec to use. Alternatively, you can use one of the APIs listed on APIs Guru. In the examples below, we will use the Spotify API Spec.
  2. Understand how entities are added to Backstage via YAML definitions. Please read the Adding Components Guide to learn more.
  3. Track a component in Backstage so we can add an API spec to it.

Adding an OpenAPI spec to a component

Step 1: Create an API kind

Create a YAML file called api-info.yaml in the root of your component, alongside your code. This file will represent your API inside Backstage.

kind: API
  name: spotify
  description: The official Spotify REST API
  type: openapi
  lifecycle: production
  owner: spotify

The API kind can take many of the normal spec properties such as owner and lifecycle.

The spec.definition.$text property must point to the remote URL of your OpenAPI spec.

Note that if you are hosting your OpenAPI specs in GitHub and referencing them with the $text property, the link must point to the URL starting with and not

Step 2: Add the API to Backstage

Once this YAML file is committed and available on GitHub, you can make Roadie Backstage aware of it using the catalog importer.

Copy the URL of the YAML spec on GitHub, paste it into the catalog importer at and click Analyze.

an input with a GitHub URL pasted into it. There is a button labelled analyze

Review the action the importer is going to take, then press Import.

a chance to review the URL which is going to be added and the name of the API which will be created

Click the name of the API to view it in Backstage.

list of the entities which have been added to the catalog with the option to click and view one

You should also be able to view your API in the list of APIs Backstage tracks by clicking the “APIs” item in the sidebar or visiting /api-docs.

list of APIs in a table showing name, description and some other properties

Now that the API is tracked in Backstage, we can associate it with a component.

In the catalog-info.yaml file of a component, add the spec.providesApis property to indicate that this component provides the spotify API.

kind: Component
  name: sample-service-2
  # Other metadata and annotations omitted for brevity.
  type: service
  owner: my-team
  lifecycle: experimental
    - spotify

The token spotify under spec.providesAPIs must match the of the API we created earlier.

A single component can provide multiple APIs.

Once this step is done correctly, we can visit the API tab of our component in Backstage to see that it provides the Spotify API.

API tab with a list of APIs the component provides. The only API in the list is the Spotify API object.

And we can click through to the definition of that API to see the specification.

a list of endpoints that Spotify exposes such as slash albums

Further reading

  1. The official Kind: API documentation.