Backstage Catalog API Migration: Step-by-Step
In this article
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
catalogApifrom the@backstage/plugin-catalog-reactpackage
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:
- Update dependencies: In your
package.json, ensure@backstage/catalog-clientis at least version 1.0.0 and@backstage/plugin-catalog-reactis at least 1.1.0. Runyarn install. - Replace the API instance: In your app's
apis.ts, change thecatalogApifromCatalogClientto the newCatalogClientfrom@backstage/catalog-client. The constructor now takes afetchApiand abaseUrl(usuallybackendUrlfrom config). - Update method calls: For each call site, change
getEntities()togetEntities(request)whererequestis an object like{ filter: { kind: 'component' } }. Similarly,getEntityByName(name)becomesgetEntityByRef(entityRef)whereentityRefis a string like'component:default/my-service'. - Handle response types: The new methods return
Promise<GetEntitiesResponse>which contains anitemsarray. Update your code to accessresponse.itemsinstead of the direct array. - Update entity shape usage: The
Entitytype now has ametadata.uidfield that is required, andmetadata.namespacedefaults to'default'. If your code assumednamespacewas optional, adjust accordingly. - Refactor tests: Mock the
CatalogClientwith a jest mock that returns the new response shapes. Usemock.paginatedEntitiesor similar utilities from@backstage/catalog-client/testUtils. - Run the Backstage CLI: Execute
yarn backstage-cli repo lintto catch any remaining deprecated imports. Then runyarn tscto check types.
Common Problems and How to Solve Them
Most migration issues fall into a few categories:
- Missing
filtersyntax: The new API requires filters as objects, not strings. For example,filter: { kind: 'component' }, notfilter: 'kind=component'. - Entity refs vs. names:
getEntityByNametook aCompoundEntityRefobject; the newgetEntityByReftakes a string. Convert withstringifyEntityRef()from@backstage/catalog-model. - Pagination changes: The new API uses
limitandoffsetparameters instead oftakeandskip. Update any pagination logic. - Type errors on
metadata: TheEntityMetatype now includesuidas required. If you create mock entities, add auidfield.
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:
| Operation | Old API | New API |
|---|---|---|
| Get all components | catalogApi.getEntities() | catalogApi.getEntities({ filter: { kind: 'component' } }) |
| Get a specific entity | catalogApi.getEntityByName({ name, kind, namespace }) | catalogApi.getEntityByRef('component:default/my-svc') |
| Get locations | catalogApi.getLocations() | catalogApi.getLocations() (mostly unchanged) |
| Add location | catalogApi.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.