Getting Started
Getting started with your 3scale API Management installation.
Abstract
Providing feedback on Red Hat documentation
We appreciate your feedback on our documentation.
To propose improvements, open a Jira issue and describe your suggested changes. Provide as much detail as possible to enable us to address your request quickly.
Prerequisite
- You have a Red Hat Customer Portal account. This account enables you to log in to the Red Hat Jira Software instance. If you do not have an account, you will be prompted to create one.
Procedure
- Click the following link: Create issue.
- In the Summary text box, enter a brief description of the issue.
In the Description text box, provide the following information:
- The URL of the page where you found the issue.
-
A detailed description of the issue.
You can leave the information in any other fields at their default values.
- Click Create to submit the Jira issue to the documentation team.
Thank you for taking the time to provide feedback.
Chapter 1. First steps with 3scale API Management
For your first steps with Red Hat 3scale API Management features, you will learn how to integrate and manage your application programming interface (API), both from customer-facing and internal perspectives.
1.1. Products and backends for 3scale API Management APIs
Red Hat 3scale API Management separates your APIs into two main groups:
A product can contain multiple backends, and a backend can be used in multiple products. In other words, to integrate and manage your API in 3scale you need to create both:
- A backend containing at least the URL of your API. The backend can optionally be configured with mapping rules, methods and metrics to facilitate reusability.
- A product for which you define the application plans, and configure APIcast.
1.2. Configuring your first API using the 3scale API Management wizard
The 3scale wizard provides initial assistance when working with products and backends.
Run the 3scale wizard only the first time you log in to your 3scale account. If you run the wizard to create subsequent 3scale components, you will overwrite existing components.
Prerequisites
- You need a 3scale account.
Procedure
Run the wizard. You can run the 3scale wizard in two ways:
- The first time you log in to your 3scale account.
Running the wizard by replacing
your_admin_domain
in the following URL address:https://<your_admin_domain>-admin.3scale.net/p/admin/onboarding/wizard/intro
For example, if your admin domain is testing-area, the wizard is available in:
https://testing-area-admin.3scale.net/p/admin/onboarding/wizard/intro
- Click OK, how does 3scale work?.
- Watch the introductory animation. Once done, click Got it! Let’s add my API.
Create a backend:
-
Specify a name for your backend. For example:
Inventory
-
Indicate a base URL for the backend. Example:
https://echo-api.3scale.net:443
- Click Add this Backend.
-
Specify a name for your backend. For example:
Create a product:
-
Indicate a product name. For example:
Petstore
- Click Add this Product.
-
Indicate a product name. For example:
Indicate a path to connect your backend to your product, and click Add the Backend to the Product.
-
You can leave the default value. Path:
/
-
You can leave the default value. Path:
To make a test with a GET request, click Send request.
- You can specify a GET method.
- After these steps, you will see a confirmation of a successful request to the API Gateway. For more details about the following configurations, click Cool, what’s next?.
Once you have taken a look at the suggested additional configurations, you are ready to use 3scale. Click Got it! Take me to my API on 3scale and you will see the Overview page of your product.
1.3. Initial API configurations to perform test calls
Initial configurations will ensure that your API traffic is protected by API keys, tracked, and monitored by 3scale with basic rate limits and controls in place. If this is the first time you are working with 3scale, you can run the wizard to get assistance configuring your first API.
1.4. Creating backends for your products
A backend is an internal API that is bundled to a product.
Prerequisites
- You need a 3scale account.
Procedure
- Go to the Dashboard.
- Under the APIs section, click Create Backend in the Backends card.
Provide the following details:
Name
Backend identifier.
System name
Identifier used for internal purposes.
Description
Optional field containing more details about the backend.
Private Base URL
Base URL endpoint of the private API.
- Click Create Backend.
After performing the steps for Creating backends for your API, you have an internal API. You can create more backends as needed.
Next steps
1.5. Creating new products to test API calls
As a 3scale API provider, create products to test API calls through these public APIs. A product is a customer-facing API that packages one or more backends.
You can create a new product by following one of these options:
- Define the product manually.
- Import the product from OpenShift.
Here you will find details about the manual definition. If you want to import a product from OpenShift, see Service Discovery.
Prerequisites
- You need a 3scale account.
Procedure
- Go to the Dashboard. Under the APIs section, click Create Product in the Products card.
Provide the following details:
Name
Product identifier.
System name
Identifier used for internal purposes. A product
system_name
is used to generate proxy endpoints and domain names. By default,system_name
is part of a label whose pattern can be as one of the alternatives below:For APIcast staging
%{system_name}-%{tenant_name}-apicast-staging
For APIcast production
%{system_name}-%{tenant_name}-apicast-production
When an auto-generated URL label exceeds 63 characters, the system shortens the label as follows:
<truncated_label>-<unique_hash>
<truncated_label>
The first 54 or 55 characters of the original URL.
<unique_hash>
The first 7 characters of a unique SHA-1 hash calculated from the original label.
For example, this is the URL before truncation:
https://my-very-long-system-name-also-very-long-tenant-name-apicast-staging.3scale.net
This is the URL after the truncation:
https://my-very-long-system-name-also-very-long-tenant-name-api-72588d2.3scale.net
Description
Optional field containing more details about the product.
- Click Create Product.
After these steps, you have a product that represents the public facing API.
Next steps
1.6. Adding backends to your products
By the end of this procedure you will have added a backend to a product. Repeat the procedure to add more backends as you require them.
Prerequisites
- A product. To create one, see Creating new products.
- One or more backends. To create one, see Creating backends for your products.
Procedure
- Navigate to [Your_product_name] > Integration > Backends.
- Click Add Backend.
From the drop down list, perform one of these actions:
- Select an existing backend.
Click View all to see the entire list.
- If you need to create a new backend, click Create new Backend and complete the details.
- Specify the routing path in the Path textbox. For more details, see The backend path of a specific product.
- Click Add to Product.
- Promote the product under the Products tab in [Your_product_name] > Integration > Configuration.
After these steps, your product will have one backend. You can repeat this procedure to add more backends to a product or to multiple products.
1.7. The backend path of a specific product
When you add a backend to a product, you define the path that the backend uses to communicate with the specified product. This path is not part of the backend.
From the procedure described in Adding backends to your products, APIcast is the API gateway that uses the path of the backend you indicated in step 4. APIcast redirects the traffic to the backend with the specified path matching the prefix of the requested endpoint path.
When defining the path for a backend:
-
You can indicate
/
as the path of one of the backends. - Paths must be unique inside the product. This means that you cannot add two backends with the same path inside the same product. Neither can you add the same backend twice to the same product.
- You can give the same backend the same path in different products.
This is how the backend path works:
- Each backend added to a product is mounted in the specified path.
- Before redirecting the traffic, the path is removed from the public URL of the request to the product.
Example
Consider this configuration to add a backend to a product:
- Backend: Inventory
-
Resource path:
/list
- Product: Petstore
-
Backend path:
/supplies
These are the URLs used by your configuration:
-
Public URL:
<public-api-domain>/supplies/list
-
Private URL:
<private-api-domain>/list
This is the action flow when a request is sent:
- The application sends a request.
-
The request is sent to the public URL:
<public-api-domain>/supplies/list
-
The backend path is removed before redirecting to the private URL:
<private-api-domain>/list
- The request is redirected to the Inventory backend.
1.8. Defining mapping rules
A mapping rule associates a call to an endpoint with designated methods and metrics for tracking and limiting access to your API. You can define mapping rules at the backend and product levels. The advantage of defining mapping rules at the backend level is that you can add a backend to multiple products. To learn more about the metrics or methods for which to collect usage information depending on the requests to your API, both at the product and backend levels, see How APIcast applies mapping rules for capturing usage of 3scale API Management APIs.
Prerequisites
- A backend. To create it, see Creating backends for your products.
Procedure
- On the Dashboard, click the Backend you want to define mapping rules for.
- In the navigation panel, click Mapping Rules.
- Click Create mapping rule.
Specify the following settings:
Verb
The HTTP request verb (
GET
,POST
,DELETE
, orPUT
).Pattern
The pattern to match. For example,
/hello
.Metric or method to increment
The metric or method name.
Increment by
The metric increment number. For example,
1
.Last?
If the request matches a rule marked Last?, APIcast stops processing and will not search for matches in the remaining mapping rules, then also stops incrementing their metrics.
Position
Number that indicates the position of the execution of the mapping rule, to sort the mapping rules.
- Click Create mapping rule.
Next steps
After these steps, the mapping rule is added to Backends under [Your_API_backend] > Mapping Rules. The mapping rule is also available for each product currently using the backend. To have the mapping rule active at the product level, promote the latest configuration under the Products tab in [Your_product_name] > Integration > Configuration.
Example
After you promote the configuration, 3scale activates the backend mapping rules at the product level. The mapping rules follow the backend path specified in the product. For example, suppose you have this configuration:
-
Pattern of the mapping rule at the backend:
/thousands
-
Backend is added to a product with path:
/unitprice
The mapping rule at the product level is: /unitprice/thousands
1.9. Creating 3scale API MAnagement application plans for products
A 3scale application plan defines the rules such as limits, pricing, and features for using your API product. For more information, refer to Application plans and Designating methods and adding metrics for capturing usage details.
Prerequisites
- A product. To create one, see Creating new products.
Procedure
- Navigate to [Your_product_name] > Applications > Application Plans.
- Click Create Application Plan.
- On the Create Application Plan page, enter a name and a system name for your new plan. A system name must be unique in your 3scale installation.
- Click Create Application Plan.
1.10. Creating applications for the default account to test API calls
As a 3scale user, create applications for the default Developer account. An application subscribes to an application plan. As a result of this subscription, 3scale provides the user key required to call an API product.
An application is always associated with an application plan. Applications are stored within developer accounts. In basic 3scale plans only a single application is allowed. In enterprise plans, multiple applications per account are allowed.
Prerequisites
- A 3scale API product. To create one, see Creating new products to test API calls.
- A 3scale application plan. To create one, see Creating 3scale application plans for products.
Procedure
- Navigate to Audience > Accounts > Listing.
- Click the default Developer account.
- Click the Applications tab.
- Click Create application.
- In the Create application dialog, select the product for the application.
- Choose an application plan.
- Specify an application name.
- In the Description field, enter information about this application.
- Click Create application.
You can see your new application in Dashboard > Audience > Accounts > Applications > Listing.
1.11. Sending requests to your product to test the integration of a backend
As a 3scale API provider, you can send a command line request to a product to test the integration of a backend based on the first mapping rule added to the product.
Before you can send a test request, you must promote an APIcast configuration that includes the backend that you want to test. A specific APIcast configuration consists of the backends you have added to a product with the corresponding mapping rules, applications, and application plans.
3scale directs requests to the backend of a product according to the path specified in the request call. For each backend of a product, you configured the backend path when you added the backend to the product. In other words, each backend has its own path.
Prerequisites
- One or more backends that you added to a product.
- A mapping rule for each backend in a product.
- An application plan to define the access policies.
- An application that subscribes to the application plan.
Procedure
Promote the new APIcast configuration to staging:
- Navigate to [Your_product_name] > Integration > Configuration.
Under APIcast Configuration, click Promote v.[n] to Staging APIcast.
- v.[n] indicates the version number to be promoted.
- If there are no changes to be promoted, there is a grayed button with the text Nothing to promote.
Under Staging APIcast, promote the APIcast configuration to production by clicking Promote v.[n] to Production APIcast.
- v.[n] indicates the version number to be promoted.
- If there are no changes to be promoted, you will see a grayed button with the text Nothing to promote.
To test requests to your API product, copy the command provided in Example curl for testing and run it in a terminal.
-
The
curl
command example is based on the first mapping rule of the product. - After you run the command, you should get an HTML response containing results from the backend you are testing.
-
If you do not get a response, delete the catch-all mapping rule from your product, promote the new APIcast configuration to staging and then to production, and run the example
curl
command.
-
The
Next steps
You can confirm the different responses when changing metrics and methods, such as limits and pricing rules. For any of the application plans of a product, modify the methods and metrics when testing requests to your product. For more details, refer to adding methods and metrics.
Every time you modify the product configuration and before making calls to your API, you must promote the updated configuration to the staging and production environments. When there are pending changes to be promoted to the staging environment, there is an exclamation mark in the Admin Portal, next to the Integration menu item.
1.12. Additional resources
Chapter 2. Launching your APIs
In this chapter, you will learn about some key steps to launch your APIs with Red Hat 3scale API Management. To use this guide, there are these assumptions:
The guide covers the following steps to launch your API product:
- Secure the product.
- Configure the product access policies with application plans.
- Engage your developers with a Developer Portal.
- Go live.
2.1. Paths to launch your first API
To begin working with 3scale, you can choose one of the three paths to launch and expose your API product. Your API product is the customer-facing API you are showing to the world.
The timing guidelines depend on the complexity of your API product and the resources you plan to dedicate to the effort. You will spend most of your time on refining your API product and preparing content for your Developer Portal. If you already have a stable product and content for documentation, you can go live within a week.
These are the paths to launch your first API product:
- Goal: Complete an end-to-end integration of 3scale with a simple API product, which will be exposed to the public.
- Recommended for: This path helps you get a general overview of the end-to-end capabilities of 3scale. You must do this path before going through Basic. If you have successfully completed the onboarding wizard in the Admin Portal, you can skip this path and go to the next one.
- Completion time: Less than an hour.
- Goal: Complete all implementation steps to launch your API product in production.
- Recommended for: If you want to go live with your API product in production and you have limited time, the Basic path will cover most of your needs.
- Completion time: Less than a week.
- Goal: Optional extras after you have completed the Basic path, such as advanced control of your API product, and deeper customization of the Developer Portal.
- Recommended for: If you have a more complex requirement or if you have covered the Basic path already, you may be ready to consider advanced options.
- Completion time: Several weeks.
2.2. Following the Prototype path
You can follow through the Prototype path individually from end to end. Alternatively, you can choose to perform some steps from this path according to your needs. Each path can be independent, but Prototype, Basic, and Advanced paths build on top of each other.
2.2.1. Securing your API
You can prototype the 3scale access control layer within a few minutes, assuming one of the following cases:
- In 3scale Hosted (SaaS), your product is publicly accessible.
- In 3scale On-premises, your product is reachable from the 3scale installation.
Echo API
serves as an example of a public product. It has the following features:
- It is a simple API that accepts any path and returns information about the request, for example, path, request parameters, headers, etc., in the response body.
- It is accessible at the following URL: https://echo-api.3scale.net
-
The first time you activate 3scale, a product is created for each existing API. In this first time, there is a one-on-one relationship between the product and the API backend. In other words, you will see:
Echo API
, a product containingAPI Backend
.
Only create a new application plans and applications if you do not use the predefined Echo API
.
Prerequisites
Procedure
Verify that your product is reachable. Example: https://echo-api.3scale.net/v1/fast/track
- After the security layer is in place, you can hide or restrict access to the backend host.
- Navigate to [Your_product_name] > Integration > Configuration.
-
For [Your_product_name], confirm that the private endpoint has been set in the default API Backend. Example:
https://echo-api.3scale.net:443
- Click the button to promote to staging.
Copy the cURL statement, which includes the
user_key
as the default credential, to make calls from the command line:curl "https://api-2445581407825.staging.apicast.io:443/v1/fast/track?user_key=287d64924e6120d215b1000ac07c063b"
You can make different calls. For example try another endpoint, adding the same
user_key
.NoteYou can get the API product keys from the application details page, located in one of the developer accounts.
Your 3scale access control layer will now only allow authenticated calls through to your backend API.
2.2.2. Configuring API access policies with application plans
After following the steps under Securing your API, only authenticated calls are allowed through to your APIs. In this section you will apply policies to differentiate the rate limits.
In 3scale, applications define the credentials to access your product. An application is always associated with one application plan that determines the access policies. Applications are stored within developer accounts. In the basic 3scale plans only a single application is allowed; but, in the higher plans, multiple applications per account are allowed.
The following prerequisites only apply if you create a new product and do not use the predefined Echo API
.
In the following example, add a policy to the Echo API
product used in the preceding section:
Prerequisites
You must create 3scale application plans for your products.
- In the following example procedure, the application plan is named Basic application plan.
- You must create applications for the default account to test API calls.
For the purpose of the following procedure example, the application plan is named Basic. Use the name you gave yours when you created the application plan.
Procedure
- Navigate to [Your_product_name] > Applications > Application Plans.
- In the Application plans section, go to the Basic application plan to edit one of the plans that was generated by the sample data after installing or signing up for 3scale.
- Under Metrics, Methods, Limits & Pricing Rules, select limits in the hits row, and create a new usage limit of 3 per hour.
- Find one of your sample applications, by navigating to [Your_product_name] > Applications > Listing. Ensure that the application is set to the Basic plan. If not, change plan on the application details page.
- Use the credentials for this application and repeat the previous sample call at least three times.
You have now successfully defined more restrictive access polices for all the applications on 3scale Basic plan.
2.2.3. Engaging developers with a Developer Portal
For the Prototype path, you do not need to create any documentation content. It is usually enough to check that the workflows meet your requirements.
While the product is in development and testing, you can disable the full self-service workflow with these steps:
- From your Admin Portal, navigate to the Audience space and click Visit Portal link in the Developer Portal menu.
- Create a test signup and walk through all the steps.
- Usually self-service is enabled by default. To change it, go to Audience > Accounts > Usage Rules and select the account approval required checkbox.
- Repeat the test signup walkthrough and verify that you need to approve the account in the Admin Portal before the user can log in.
You can now successfully customize workflows for your Developer Portal.
2.3. Following the Basic path
You can follow through the Basic path individually from end to end. Alternatively, you can choose to perform some steps from this path according to your needs. Each path can be independent, but Prototype, Basic, and Advanced paths build on top of each other.
2.3.1. Securing your API
For a full production implementation, you need to make some fundamental decisions about how to structure your product and implement integration with 3scale.
You have the choice of several authentication modes for product traffic. Consult the guide on the available options and configure the settings.
After you set the authentication, you should not switch authentication modes because this action might invalidate existing credentials.
Additional resource
Hosted APIcast
- Follow the onboarding wizard after you log in to your Admin Portal for the first time.
- Continue iterating on your product configuration, such as refining access policies, until you have reached a version suitable for production.
- Promote your APIcast configuration to the production gateway.
Self-managed APIcast
- Deploy the APIcast gateway self-managed solution using the operator on OpenShift.
- Continue iterating on your API configuration, such as refining access policies until you have reached a version suitable for production.
- Promote your APIcast configuration to the production gateway.
- For further details about self-managed APIcast, see Installing APIcast.
2.3.2. Configuring API access policies with application plans
After following the steps under Securing your API, only authenticated calls are allowed through to your product. In this section you will apply policies to differentiate rate limits.
In Red Hat 3scale API Management, applications define the credentials to access your API product. An application is always associated with one application plan that determines the access policies. Applications are stored within developer accounts. In the basic 3scale plans, only a single application is allowed. In the higher plans, multiple applications per account are allowed.
In Prototype, you can only control access based on overall hits on your product. The flexibility of 3scale is evident after you start using custom methods and metrics to create more sophisticated tiers for your application plans and for deeper analytic insight to your product. For more details, see the analytics guide.
- The mapping between your API structure and methods or metrics in 3scale is logical. You can get reports of the product usage from 3scale if you define a consistent rule. You must determine the level of detail. Generally, you should aim between 5 and 20 methods/metrics.
- The values reported to 3scale can only be incremented. You cannot set absolute values or decrease the counters.
- After adding any new methods or metrics to 3scale, it is important to add the new system names to your integration point.
- You can make changes, such as rate limits, at runtime without redeploying.
Only create a new application plans and applications if you create a new product and do not use the predefined
Echo API
:
Prerequisites
You must create 3scale application plans for your products.
- In the following example procedure, the application plan is named Basic application plan.
- You must create applications for the default account to test API calls.
For the purpose of the following procedure example, the application plan is named Basic. Use the name you gave yours when you created the application plan.
Procedure
- Navigate to [Your_product_name] > Applications > Application Plans.
- In the Application plans section, go to the Basic application plan to edit one of the plans that was generated by the sample data after installing or signing up for 3scale.
- Under Metrics, Methods, Limits & Pricing Rules, select limits in the hits row, and create a new usage limit of 3 per hour.
- Find one of your sample applications, by navigating to [Your_product_name] > Applications > Listing. Ensure that the application is set to the basic plan. If not, change plan on the application details page.
- Use the credentials for this application and repeat the previous sample call at least three times.
You have now successfully defined more restrictive access polices for all the applications on 3scale Basic plan.
APIcast deployment
- Go to [Your_product_name] > Integration > Configuration.
Expand the mapping rules section and add the following mappings:
NoteThe default mapping for "/" has been removed. If you use this default mapping, it will lead to double-counting of hits.
2.3.3. Engaging developers with a Developer Portal
You can find information to create and provide APIs using the Developer Portal. Consider writing your content in Textile or Markdown. Following are optional steps that you may want to consider:
- Configure ActiveDocs to bring interactive capabilities to your documentation and make it easier for developers to explore.
- Add a favicon.
- Add your Google Analytics tracker code by editing partial in your CMS called analytics.
- Configure your signup workflows.
- Customize your email template content.
2.4. Following the Advanced path
You can follow through the Advanced path individually from end to end. Alternatively, you can choose to perform some steps from this path according to your needs. Each path can be independent, but Prototype, Basic, and Advanced paths build on top of each other.
2.4.1. Securing your API
To secure your product, you have the following alternatives:
Advanced authentication mode: OpenID Connect (OIDC)
Secure your products using the APIcast integration with OpenID Connect for Red Hat Single Sign-On. Applications in 3scale are synchronized with the Identity Provider (IdP), in this case Red Hat Single Sign-On. Currently, this is an end-to-end supported solution. It covers the main OAuth 2.0 flows:
- Authorization code
- Resource owner password
- Client credentials
- Implicit grant
2.4.2. Configuring API access policies with application plans
With the options listed under Securing your API, you ensured that only authenticated calls are allowed through to your product. In this section, you apply policies to differentiate rate limits.
In 3scale, applications define the credentials to access your product. An application is always associated with one application plan that determines the access policies. Applications are stored within developer accounts. In the Basic 3scale plans, only a single application is allowed. In the higher plans, multiple applications per account are allowed.
Alerts may be configured to send notifications by email or to the web consoles:
- Go to your API Settings page: [Your_product_name] > Applications > Settings > Usage Rules.
- Go to the Alerts section on the page. Here, you can configure the alerts that you want as a percentage of your rate limit levels.
3scale gives you the flexibility to decide on the level of rate limits:
- Soft rate limits: Even calls above the limits are allowed through.
- Hard rate limits: Calls are rejected before hitting your application.
APIcast defines hard limits by default. These can be customized in the Lua file to avoid rejecting over-limit calls.
2.4.3. Engaging developers with a Developer Portal
After you have completed the Basic path, following are two advanced areas you can explore for the Developer Portal:
- Liquid markup provides tags and drops that provide direct access to system objects and allow you to introduce dynamic rendering of developer portal pages.
- All 3scale system pages can be customized. This is for advanced users because the HTML is complex. Ultimately, you can customize virtually any page of your Developer Portal. Usually the default pages will be perfectly fine with some CSS changes.
2.5. Going live
This section describes the final checklist before the public launch of your API product.
Raise request for the custom domain and email as soon as possible because they have a long lead time.
- In Audience > Developer Portal > Settings > Domains & Access, type a custom domain in the Developer Portal Site field.
- Optionally, type a custom outbound email address in the Outgoing Email field.
- Remove the Developer Portal access code.
- Click Update Account to save changes.
Following are some extra points for consideration:
- Add pricing to generate earnings directly from your API product. This feature is only available for 3scale Hosted (SaaS) accounts.
- Use insight from your product analytics, in your Admin Portal located under Analytics, to refine your application plans.