The Wild

Backstage Catalog API Migration: Step-by-Step

· 5 min read · Mammals

In this article
  1. Background: Why the Catalog API Changed
  2. Assessing Your Current Migration Scope
  3. Step-by-Step Migration Process
  4. Common Problems and How to Solve Them
  5. Comparing Old and New API Patterns
  6. Costs and Risks of Delaying Migration
  7. Safety and Testing Best Practices
  8. Frequently Asked Questions

To migrate the Backstage catalog API, you need to update your custom backend plugins and frontend components from the deprecated CatalogApi methods to the new CatalogClient with explicit request/response types, then refactor any code that relied on the old Entity shape. This guide walks through the full process, from assessing your current usage to testing the migration.

Background: Why the Catalog API Changed

Backstage, Spotify's open-source developer portal, has evolved its catalog API over several releases. The old API exposed methods like getEntities(), getEntityByName(), and getLocationByRef() that returned raw Entity objects. These methods were convenient but tightly coupled to the internal storage format, making it hard to add features like filtering, pagination, and permission checks. The new API, introduced in Backstage 1.0, uses a CatalogClient that talks to the catalog backend via REST endpoints, with typed request and response objects. This separation allows the backend to evolve independently and gives frontend developers clearer contracts.

Assessing Your Current Migration Scope

Before touching any code, map out every place your project uses the catalog API. Common areas include:

  • Custom plugins that fetch entities for display or processing
  • Utility functions that wrap catalog calls
  • Tests that mock the catalog API
  • Any code using catalogApi from the @backstage/plugin-catalog-react package

Search your codebase for imports like @backstage/catalog-client and @backstage/plugin-catalog. The Backstage CLI has a backstage-cli repo lint command that can flag deprecated API usage, but a simple grep for getEntities( and getEntityByName( will give you a quick list. Also check for any direct imports of Entity from @backstage/catalog-model—those types may have changed too.

Step-by-Step Migration Process

Follow these steps in order to avoid breaking your build:

  1. Update dependencies: In your package.json, ensure @backstage/catalog-client is at least version 1.0.0 and @backstage/plugin-catalog-react is at least 1.1.0. Run yarn install.
  2. Replace the API instance: In your app's apis.ts, change the catalogApi from CatalogClient to the new CatalogClient from @backstage/catalog-client. The constructor now takes a fetchApi and a baseUrl (usually backendUrl from config).
  3. Update method calls: For each call site, change getEntities() to getEntities(request) where request is an object like { filter: { kind: 'component' } }. Similarly, getEntityByName(name) becomes getEntityByRef(entityRef) where entityRef is a string like 'component:default/my-service'.
  4. Handle response types: The new methods return Promise<GetEntitiesResponse> which contains an items array. Update your code to access response.items instead of the direct array.
  5. Update entity shape usage: The Entity type now has a metadata.uid field that is required, and metadata.namespace defaults to 'default'. If your code assumed namespace was optional, adjust accordingly.
  6. Refactor tests: Mock the CatalogClient with a jest mock that returns the new response shapes. Use mock.paginatedEntities or similar utilities from @backstage/catalog-client/testUtils.
  7. Run the Backstage CLI: Execute yarn backstage-cli repo lint to catch any remaining deprecated imports. Then run yarn tsc to check types.

Common Problems and How to Solve Them

Most migration issues fall into a few categories:

  • Missing filter syntax: The new API requires filters as objects, not strings. For example, filter: { kind: 'component' }, not filter: 'kind=component'.
  • Entity refs vs. names: getEntityByName took a CompoundEntityRef object; the new getEntityByRef takes a string. Convert with stringifyEntityRef() from @backstage/catalog-model.
  • Pagination changes: The new API uses limit and offset parameters instead of take and skip. Update any pagination logic.
  • Type errors on metadata: The EntityMeta type now includes uid as required. If you create mock entities, add a uid field.

If you see errors about CatalogApi not being exported, you likely still have an old version of @backstage/plugin-catalog. Remove that import and use @backstage/catalog-client instead.

Comparing Old and New API Patterns

The table below contrasts the most common operations:

OperationOld APINew API
Get all componentscatalogApi.getEntities()catalogApi.getEntities({ filter: { kind: 'component' } })
Get a specific entitycatalogApi.getEntityByName({ name, kind, namespace })catalogApi.getEntityByRef('component:default/my-svc')
Get locationscatalogApi.getLocations()catalogApi.getLocations() (mostly unchanged)
Add locationcatalogApi.addLocation({ type, target })catalogApi.addLocation({ type, target }) (unchanged)

Notice that addLocation and getLocations remained stable, so if your code only uses those, migration is trivial.

Costs and Risks of Delaying Migration

There is no direct monetary cost to migrating, but there are opportunity costs. The old API is deprecated and will be removed in a future Backstage release. Delaying means:

  • Your plugins may break when you upgrade Backstage core.
  • You miss out on new features like filtering by relations and permissions.
  • Your code becomes harder to maintain as the community moves on.

The migration itself is mostly mechanical and can be done incrementally, plugin by plugin. The risk is low if you have good test coverage.

Safety and Testing Best Practices

Before deploying the migration, ensure you have a staging environment that mirrors production. Run the Backstage backend with the new catalog API and verify that:

  • All entities appear correctly in the UI.
  • Search still works.
  • Permission policies still apply.
  • Any custom processors or providers still function.

Use the @backstage/test-utils to write integration tests that exercise the catalog API against a mock backend. The Backstage documentation recommends using MockFetchApi to simulate responses.

Frequently Asked Questions

Do I need to migrate if I only use the catalog UI?

If you haven't written any custom code that calls the catalog API directly, you don't need to change anything. The built-in catalog plugin was already migrated internally. However, if you use any third-party plugins that are outdated, they may need updates.

Can I keep the old API as a compatibility layer?

You can write a wrapper that mimics the old API using the new client, but it's not recommended. The old API will be removed eventually, and maintaining a shim adds unnecessary complexity. It's better to update your code.

How do I handle entity filters that used to be strings?

Convert string filters to objects. For example, filter: 'kind=component' becomes filter: { kind: 'component' }. For multiple conditions, use an array of objects: filter: [{ kind: 'component' }, { namespace: 'default' }].

What is the difference between getEntityByRef and getEntityByName?

getEntityByRef takes a string in the format kind:namespace/name, while the old method took a structured object. The new method is more flexible because it accepts any valid entity reference, including those with optional namespace.

Will my custom entity providers break?

Entity providers are backend components that feed data into the catalog. They don't use the catalog API directly; they use the CatalogBuilder or CatalogClient internally. If you wrote a custom provider, check that it uses the latest @backstage/plugin-catalog-backend APIs. The migration steps above apply to frontend and backend plugins that consume the catalog, not to providers themselves.