Import API Contract¶
An API proxy acts as an intermediary between an existing API and API Platform, intercepting all requests made to the API.It also functions as a managed API, allowing you to apply essential API management features such as security policies and rate limiting.
In this guide, you will:
- Create an API proxy.
- Configure and Deploy the API proxy.
- Test the API proxy to verify its functionality.
Prerequisites¶
- If you're signing in to the API Platform Console for the first time, create an organization:
- Go to API Platform Console and sign in using your preferred method.
- Enter a unique organization name. For example,
Stark Industries. - Read and accept the privacy policy and terms of use.
- Click Create.
This creates the organization and opens the Project Home page of the default project created for you.
Create an API Proxy¶
In this guide, you will specify a URL to an OpenAPI definition of a sample API to create an API proxy.
- Go to API Platform Console and sign in. This opens the project home page.
- If you already have one or more components in your project, click + Create. Otherwise, proceed to the next step.
- Select Import API Contract.
- Select URL option and provide the following URL to import the API contract from the GitHub repository:
- Click Next and edit pre-defined values as needed. You can keep the default values for this sample.
- Click Create to create the API Proxy. Wait for the setup to complete.
Configure and Deploy the API Proxy¶
- Navigate to the Deploy page of the API Proxy.
- Select Configure and Deploy option from the Deploy dropdown and click it.
- Select External as API Access Mode.
- Click Deploy.
Test the API Proxy¶
- Navigate to the Test → OpenAPI Console page of the API Proxy.
- Use the OpenAPI Console to test the API Proxy.
Promote the API Proxy to Production and Publish the API Proxy¶
- Navigate to the Deploy page of the API Proxy.
- Click Promote. This promotes the API proxy from the Development environment to the Production environment.
- In the left navigation menu, click Lifecycle under Develop. This takes you to the Lifecycle page.
- Click Publish.
- In the Publish API dialog, click Confirm to proceed with publishing the API. If you want to change the display name, make the necessary changes and then click Confirm. This sets the API lifecycle state to Published.
API Proxy Behavior¶
The Reading List API Proxy provides the following functionality:
- GET /books: Returns a list of pre-defined books with a warning that changes are not persisted.
- POST /books: Adds a new book to the reading list (without including
idin the request body). Returns the created book along with a warning that changes are not persisted. - PUT /books/{id}: Updates the status of an existing book. The request body only includes the
statusto update, and theidis passed in the URL. Returns the updated book with a warning. - GET /books/{id}: Retrieves a book by its
id. If theiddoes not exist, a 404 error is returned. - DELETE /books/{id}: Deletes a book by its
id.