While an API is the published interface, a corresponding service running in the back-end handles its actual implementation. APIs have their own lifecycle, independent from the back-end service they rely on. This section covers the following:
The default API lifecycle
The default API lifecycle has the following stages:
- CREATED: API metadata is saved, but it is not visible to subscribers yet, nor deployed to the API Gateway.
- PROTOTYPED : API is deployed and published in the API Store as a prototype. A prototyped API is usually a mock implementation made public in order to get feedback from users about its usability. Users cannot subscribe to a prototyped API. They can only try out its functionality.
- PUBLISHED: API is visible in API Store, and eventually published if the
Propagate Changes to API Gatewayoption is selected at publishing time.
- DEPRECATED: API is still deployed into API Gateway (available at runtime to existing users), but not visible to subscribers. An API is automatically deprecated when a new version is published.
- RETIRED: API is unpublished from the API gateway and deleted from the store.
- BLOCKED: Access is temporarily blocked. Runtime calls are blocked and the API is not shown in the API store anymore.
The diagram below shows the general API and backend service life cycle elements.
Figure: API and backend service life cycle elements
API Publisher has a separate tab called Lifecycle using which you can publish APIs to the API Store, depreciate, retire and perform other operations to an API. The Life Cycle tab is only visible to and manageable by a user who is assigned the publisher role. For instructions on creating a user with the publisher role, see Managing Users and Roles.
Let's take a look at how to perform some common life cycle operations on an API.
Publishing an API
- Log in to the API Publisher (https://<HostName>:9443/store) as a user who has the
publisherrole assigned. See Managing Users and Roles.
- Click on an API that you want to publish.
The API's overview window opens. Click the Life Cycle tab, which displays the API's available states.
To publish the API, select the PUBLISHED state from the drop-down list. You get three check boxes to select as follows:
Propagate Changes to API Gateway
Used to define an API proxy in the API Gateway runtime component, allowing the API to be exposed to the consumers via the API Gateway. If this option is left unselected, the API metadata will not change and you will have to manually configure the API Gateway according to the information published in the API Store.
Deprecate Old Versions
If selected, any prior versions of the API will be set to the DEPRECATED state automatically.
Invalidates current user subscriptions, forcing users to subscribe again.
- Select the necessary options and click the Update button to publish the API to the API Store.
Similarly, you can deprecate, retire and block APIs.
Publishing to multiple external API stores
API publishers can share an API to application developers who are subscribed to multiple tenant-specific API Stores. This allows them to expose APIs to a wider community.
After publishing an API to external stores, it will be visible to the users of those stores. However, to subscribe to the API, the users must visit the original publisher's store.
Follow the steps below to configure:
- Log in to APIM admin console (
https://<Server Host>:9443/carbon) as admin and select Browse menu under Resources .
The Registry opens. G o to
Click the Edit as Text link and change the
<ExternalAPIStores>element of each external API store that you need to publish APIs to. For example,
Note the following in the configuration above:
<ExternalAPIStore id="" type="">
id: The external store identifier, which is a unique value.
type: Type of the Store. This can be a WSO2-specific API Store or an external one.
URL of the API store of the current APIM deployment. This is the URL to the API in the original publisher's store. APIs that are published to external stores will be redirected to this URL.
The name of the Store that is displayed in the publisher UI.
URL of the API Store.
Credentials of a user who has permissions to create and publish APIs.
Registry changes are applied dynamically. You do not need to restart the server.
Using the management console, create an API.
Click on the newly created API to see a new tab c alled External API Stores added to the API Publisher console.
Note the following:
- You can select multiple external API stores and click Save to publish your API to them.
- I f the API creator updates the API after publication to external stores, either the creator or a publisher can simply push those changes to the published stores by selecting the stores and clicking Save again.
- If the API creator deletes the API, each external store that it is published to will receive a request to delete the API.
Log in to an external API store where the API is published to and click it to open.
A link appears as View Publisher Store and it directs you to the original publisher’s store through which you can subscribe to the API.
Next, see how to manage subscriptions and access tokens in Managing API Usage.