API CatalogItem
APICatalogItem
is a resource in Traefik Hub that defines which APIs are visible to users in the Developer Portal. It allows API managers to control the visibility of APIs and API Bundles to specific user groups,
ensuring that API consumers only see the APIs they are authorized to access.
By using APICatalogItem
, you can:
- Specify which APIs or API Bundles are displayed to specific user groups.
- Control the visibility of specific operations within APIs.
APICatalogItem
focuses on visibility in the Developer Portal, whereas gateway consumption access is managed through ManagedSubscription.
APICatalogItem behavior
Key Concepts
- API: A service exposed via Traefik Hub that can be documented and consumed.
- API Bundle: A collection of APIs grouped together for easier management.
- API Plan: Defines the available plans that users can subscribe to when accessing an API.
- Operation Filter: Allows you to limit the visibility of specific operations within an API.
- Groups: User groups defined in your Identity Provider (IdP) or Traefik Hub, used to control access.
How APICatalogItem
works
- Define
APICatalogItem
:
- API Publishers create
APICatalogItem
resources to specify which APIs or API Bundles are visible to specific user groups. - Optionally, limit the visible operations using
operationFilter
.
- User Groups:
- Users are associated with groups, typically defined in your IdP.
APICatalogItem
uses these groups to control which users see which APIs.
- Developer Portal:
- Users log into the Developer Portal.
- They see APIs and API Bundles as defined by the
APICatalogItem
resources targeting their groups.
Creating an APICatalogItem
APICatalogItem
resources are defined using the Custom Resource Definition (CRD) in Kubernetes. Below is an example of how to create an APICatalogItem
.
Example Scenario: Making APIs visible to external partners
Scenario: You want to make weather-api
and forecast-api
visible to users in the external group, allowing them to see the APIs on the Developer Portal and subscribe to the standard-plan.
Step 1: Define the APIs
- Weather API
- Forecast API
apiVersion: hub.traefik.io/v1alpha1
kind: API
metadata:
name: weather-api
namespace: apps
spec: {} # Additional specifications for the weather API
apiVersion: hub.traefik.io/v1alpha1
kind: API
metadata:
name: forecast-api
namespace: apps
spec: {} # Additional specifications for the forecast API
Step 2: Define the API Plan
- Standard Plan
apiVersion: hub.traefik.io/v1alpha1
kind: APIPlan
metadata:
name: standard-plan
namespace: apps
spec:
title: "Standard Plan"
description: "Standard rate limits and quotas"
rateLimit:
limit: 10
period: 1s
quota:
limit: 1000
period: 720h # Approximately 30 days
Step 3: Create the APICatalogItem
- APICatalogItem
apiVersion: hub.traefik.io/v1alpha1
kind: APICatalogItem
metadata:
name: external-api-catalog
namespace: apps
spec:
groups:
- external
apis:
- name: weather-api
- name: forecast-api
apiPlan:
name: standard-plan
Configuration Options
Field | Description | Required |
---|---|---|
groups | A list of user groups that will see the APIs. | Yes |
everyone | A boolean indicating that all users will see the APIs. | No |
apis | A list of APIs to be made visible. | Yes |
apiPlan | The API plan that defines the consumption policies for the APIs. | Yes |
apiSelector | A label selector to dynamically include APIs based on labels. | No |
apiBundles | A list of API Bundles to be made visible. | No |
operationFilter | Limits the visible operations within the APIs. | No |
Outcome
- Developer Portal
- Traefik Hub Dashboard
- Users in the
external
group can seeweather-api
andforecast-api
on the Developer portal.
Using API Bundles
If you have APIs grouped into an APIBundle
, you can include the bundle in the APICatalogItem
.
- Define the API Bundle
- APICatalogItem the API Bundle
apiVersion: hub.traefik.io/v1alpha1
kind: APIBundle
metadata:
name: weather-bundle
namespace: apps
spec:
apis:
- name: weather-api
- name: forecast-api
apiVersion: hub.traefik.io/v1alpha1
kind: APICatalogItem
metadata:
name: external-api-catalog-bundle
namespace: apps
spec:
groups:
- external
apiBundles:
- name: weather-bundle
apiPlan:
name: standard-plan
Outcome
- Users in the
external
group can see all APIs within theweather-bundle
in the Developer portal.
API Selector
You can use apiSelector
to dynamically include APIs based on labels in your Managed Subscriptions.
apiVersion: hub.traefik.io/v1alpha1
kind: APICatalogItem
metadata:
name: weather-api-catalog
namespace: apps
spec:
groups:
- external
apiSelector:
matchLabels:
category: weather
apiPlan:
name: standard-plan
Please refer to the detailed documentation about Label selectors.
OperationFilter
You can restrict which operations within an API are visible to users using the operationFilter
option.
- API
- APICatalogItem
apiVersion: hub.traefik.io/v1alpha1
kind: API
metadata:
name: my-api
namespace: apps
spec:
openApiSpec:
path: /openapi.yaml
operationSets:
- name: get-employees
matchers:
methods: ["GET"]
path: "/employees"
- name: get-payrolls
matchers:
methods: ["GET"]
path: "/payrolls"
apiVersion: hub.traefik.io/v1alpha1
kind: APICatalogItem
metadata:
name: limited-api-catalog
namespace: apps
spec:
groups:
- external
apis:
- name: my-api
operationFilter:
include:
- get-employees
- get-payrolls
apiPlan:
name: standard-plan
Frequently Asked Questions
-
How does
APICatalogItem
differ fromManagedSubscription
?APICatalogItem
: Controls visibility of APIs and API Bundles on the Developer Portal for specific user groups.ManagedSubscription
: Grants gateway consumption access to applications, specifying which applications can consume which APIs under which plans.
-
Can I use both groups and everyone in
APICatalogItem
?No,
groups
andeveryone
are mutually exclusive. You should use one or the other. -
Is there a limit to the number of APIs and API Bundles in an
APICatalogItem
?Yes, you can specify up to 100 APIs and 100 API Bundles per
APICatalogItem
. However, this limit is only on theapis
andapiBundles
fields, you can select as many objects as you wish with selectors.
Related content
- Learn more about the API object in its dedicated section.
- Learn more about the
APIPlan
resource in its dedicated section. - Learn more about the API Portal in its dedicated section.
- Learn more about Users & Groups in its dedicated section.