| title | Package APIs | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| content_type | reference | ||||||||||||||||||||
| layout | reference | ||||||||||||||||||||
| products |
|
||||||||||||||||||||
| breadcrumbs |
|
||||||||||||||||||||
| tags |
|
||||||||||||||||||||
| min_version |
|
||||||||||||||||||||
| works_on |
|
||||||||||||||||||||
| api_specs |
|
||||||||||||||||||||
| search_aliases |
|
||||||||||||||||||||
| description | Learn how to package APIs in Catalog and Dev Portal and what API packages are. | ||||||||||||||||||||
| related_resources |
|
{:.success}
This is a reference guide, you can also follow along with our Package APIs for partners with Dev Portal tutorial.
You can compose API packages from existing APIs in Dev Portal. API packages allow you to:
- Create distinct APIs for specific use cases or partners based on existing API operations.
- Link to multiple Gateway Services and/or Routes for developer self-service and application registration.
- Apply rate limiting policies to an API Package, or per operation.
- Manage role-based access control to specific developers and teams.
The following table describes common API package use cases:
{% table %} columns:
- title: Use case key: use-case
- title: Description key: description
- title: Example key: example rows:
- use-case: Customize APIs for partners
description: Using API packages, you can customize which operations/endpoints are included in Dev Portals for partners.
example: |
If you have multiple APIs/services, you can select specific operations from each API (for example,
GET /billingandGET /flights) creating an API package for partners in an external Dev Portal, called "Flight Billing API". Meanwhile, Billing and Flights APIs can also be published to your internal Dev Portal. - use-case: Apply rate limits to applications
description: While Gateway Services or Routes may have systemic rate limits in place, it's often necessary to apply lower rate limits to applications when exposing those capabilities to partners.
example: |
When creating the "Flight Billing API" package,
GET /billingmay need a lower rate limit of 10 request per minute, while the overall API package could have something higher, like five requests per second. {% endtable %}
API packages are composed from operations. Operations allow you to compose REST-style APIs from a combination of the hostname, path, and method that are processed by the control plane. They are used to map between the operations in your API and Gateway Routes. If an OpenAPI spec is added to the API, the operations are autogenerated.
The following diagram shows an example of how API packages can be composed from operations:
{% mermaid %} flowchart LR subgraph subGraph0["Control plane"] 1["Billing Gateway Service"] 2["Flights Gateway Service"] end subgraph subGraph1["Partners API package"] 3["POST /flights"] 4["GET /flights"] end subgraph subGraph2["Org API package"] 5["POST /billing"] 6["GET /billing"] 7["POST /flights"] 8["GET /flights"] end 1 --> 5 & 6 2 --> 7 & 8 & 3 & 4 {% endmermaid %}
Packaging APIs involves the following steps:
- Create an API and attach an OpenAPI spec. Operations from your API's OpenAPI spec should overlap with Routes to ensure requests will be routed to the correct Service. Gateway routing configuration isn't directly modified by adding operations.
- Link a control plane to allow developer consumption.
- Apply the Access Control Enforcement (ACE) plugin globally.
- Create an API package by adding operations and package rate limits. Operations are automatically mapped to Routes using your API's OpenAPI spec or you can create them manually. The Gateway configuration isn't directly modified – any unmatched operations will be highlighted to indicate that a user needs Gateway Manager permissions needs to perform an action.
{% include plugins/ace/ace-overview.md %}
{% include plugins/ace/ace-route-matching.md %}
You can set individual rate limits on an API package as well as operations in that package. Keep the following in mind when configuring rate limits:
- API package rate limits apply across all operations in the API package cumulatively, not individually.
- Each operation in an API Package can additionally have an individual rate limit defined. When an operation-level override is present, the package-level limit is ignored for that operation.
- API package rate limits are applied simultaneously with rate limits from other plugins on gateway entities:
- Requests that are under the current limit for the Service and API Package will be counted towards both.
- Requests that surpass the rate limit of an API package won't be counted towards rate limits applied from other rate limiting plugins.
- Requests that surpass the rate limit of other rate limiting plugins are still counted towards the rate limits applied for API packages. This is because the ACE plugin runs before other rate limiting plugins under the default plugin priorities. You can adjust this behavior with custom plugin priority values.
- Rate limiting is applied per credential.
For example, if you have the following rate limits set:
- API package A: 10 requests per second
- Operation 1: 5 requests per second
Because an operation-level override is present, the package-level limit is ignored for that operation. This means a request authorized for Operation 1 will only count toward its specific operation-level limit. So, if one request is sent, the authorized application will have four requests remaining for Operation 1 for the configured time period (per second). The package-level limit of API Package A doesn't apply to this request.
When configuring API packages, keep the following limitations in mind:
- If you have two endpoints in your spec, one with a trailing slash and one without, both are generated as the same operation.
- If two operations have the same path and method, they are generated as the same operation.
- All operations for a control plane are removed when you unlink the control plane.
- APIs can only be mapped to one control plane at a time.
- You can't change a version or edit a spec for an API if it would remove an operation because this would result in a breaking change. To remove an operation, we recommend unlinking the control plane from the API.
This guide shows you how to create an API package in the {{site.konnect_short_name}} UI.
For an end-to-end tutorial with sample data that walks you through setting up and using API Packages, see Package APIs with Dev Portal.
To package APIs with Dev Portal, you need:
- A v3 Dev Portal created in {{site.konnect_short_name}}
- A Gateway Service and/or Route added to your control plane ({{site.base_gateway}} 3.13 or later)
- The following roles:
- Editor role for APIs
- Publisher role for the API and API package
- API Creator
- An API created with an OpenAPI spec associated with it
- A Gateway control plane linked to your API in Catalog > APIs
- In {{site.konnect_short_name}}, click Catalog.
- Click the API packages tab.
- Click Create API package.
- In the API package name field, enter a name for your package.
- Enable the Package rate limit and configure your rate limit.
- Click Add operations from APIs in the API operations settings.
- In the Add API operations pane, click your API and click Add next to the operations you want to package.
- Click Create API package.
Your operations should now be autogenerated based on how your OpenAPI spec maps to your Routes.
After you've created an API package, you can edit it to upload an image for the package that will display in Dev Portals where the package is published. The image must be a PNG, JPG, or SVG image under 500 KB that’s no larger than 350 × 350 pixels.
- In {{site.konnect_short_name}}, click Catalog.
- Click the API packages tab.
- Click your API package.
- Click Publish API.
- From the Portal dropdown menu, select your Dev Portal.
- From the Authentication strategy dropdown menu, select an auth strategy.
- Click Public.
- Click Publish API.
Your API package will now be published to your Dev Portal. Published API packages appear the same as published APIs in the Dev Portal, and both allow developers to register applications with them.