How to Add an API to WSO2 API Manager
- To get to the WSO2 Publisher, navigate to https://api-qa.ucsd.edu/publisher. ( To migrate an API to production, you will need to send a request to middleware and integration team)
- You will be redirected to the UCSD Login screen. Please log in using your SSO credentials.
- Note: if you are denied access, you probably have not been granted permission to use the publisher. Please contact the WSO2 team to request access.
- You will be greeted by the Publisher home page, which looks like this:Â
- On the left-hand side, you'll see a list of options: Browse, Add, All Statistics, My APIs, Subscriptions, and Statistics.Â
- "Browse" enables you to browse through all of the currently-existing APIs, view, and edit them. (Note: The home page defaults to "Browse.")
- "Add" enables you to add a new API to WS02.Â
- "All Statistics" enables you to view statistics for all APIs.
- "My APIs" enables you to view only your own APIs.
- "Subscriptions" allows you to view a list of users who have subscribed applications to your APIs. You will also be able to see subscription activity.
- "Statistics" allows you to view statistics regarding your own APIs.
- On the left-hand side, you'll see a list of options: Browse, Add, All Statistics, My APIs, Subscriptions, and Statistics.Â
- To add an API to WS02, click the Add button on the left hand side of the page:
- You will be presented with three options. Please select the one that best fits your needs:
- "I have an Existing API" - Use if you have existing RESTful API endpoints. If you have one, you can give WSO2 a swagger document at this point, and it will pre-populate a large amount of information for you.Â
- "I have a SOAP Endpoint" - Use if you have existing SOAP endpoints. If you have one, you can provide WS02 with a WSDL URL.
- "Design a new API" - Use if you are looking to prototype and mock a non-existent API Endpoint. This option will not allow you to connect to a real backend.Â
* Note * - For this example, we will be selecting the "I have an existing API" option and not giving a swagger document - Select your option and then click "Start Creating"
- The first step in creating your API is the "Design" stage. Here you will enter in all of the descriptive information about your API and its routes. First, we will fill out the "General Details" section (see image below). The section includes the following information:
- Name (Required) - The human-readable name for your API. This will be displayed on the store.
- Context (Required) - The URL context path that will be used for access to your API. (i.e., /domains/{domain_name} for a Domain/Team specific API. For standard, general purpose apis, please contact integration services team
- Version (Required) - The current version of your API. You will be able to update versions in the future. We typically like to stick with the V1, V2 style of API versioning.Â
- Visibility (Required) - "Public" means that your API will be visible to anyone who has access to the store. "Restrict by roles" allows you to restrict visibility to a list of comma-separated LDAP groups.
- Thumbnail Image (Optional) - This thumbnail will be displayed in the store.
- Description (Highly Recommended) - While not required, we highly recommend (and request) that you put in a short description about your API, describing what it is used for and what it provides.
- Tags (Highly Recommended) - Tags help organize your API into the "groups" that you see in the API store. It also makes searching easier.Â
- Note: There are several fields that have little question-mark symbols on the right-hand side. By clicking these, you will be given further details regarding the proper use of the field/option.Â
- The next step is to fill out the "API Definition" section (located underneath the "General Details" section). This can be done in several ways:
- By importing an existing Swagger document. This can be done by clicking the "Import" button.
- By editing the definition in a WSO2 swagger editor. This can be done by clicking the "Edit Source" button.Â
- Please note that this option is only recommended if you are comfortable creating and editing raw Swagger documents
- By using the WSO2 UI to define your routes. This can be done in the UI on the bottom half of the page.
- This is the option we will be using in this example to define our API.Â
- By importing an existing Swagger document. This can be done by clicking the "Import" button.
- To define your routes in the WS02 UI, first delete the existing wildcard routes.
- These routes are designed to let every request through. This is not what we typically want for our behavior, because it prevents WSO2 from being able to stop invalid traffic and does not produce very usable documentation. Instead of letting every request through, we want to create a white-list of approved requests.
- To delete the existing wildcard routes, simply click on the trashcan icons, located on the right-hand side (see image below).
- For each route/endpoint in your API please do the following:Â
- Enter the route into the "URL Pattern" field.
- Select which methods are allowed on the route (Get, Post, Put, Delete, Head, or Options [To view "Options", you have to select "more"]).
- Click the "Add" button to add the route.
- You should now have one new route for each method that you selected. These routes will show up below.Â
- Enter the route into the "URL Pattern" field.
- Now, we need to edit the details for each of the routes that you entered. For each route or method entry please do the following:
- Click on the path name to expand the details of the route (see image below).
- (Optional, but highly recommended) Click on the "+ Summary" link to add a short summary about the endpoint.
- (Optional but highly recommended) Click on "+ Add Implementation Notes" to add a longer description about what the endpoint does.
- Click the "Empty" link next to "Produces:" and enter the MIME type that the service produces (more information about the MIME types can be found here:Â http://swagger.io/specification/#mimeTypes).
- Click the "Empty" link next to "Consumes:" and enter the MIME type that the service consumes (,ore information about the MIME types can be found here:Â http://swagger.io/specification/#mimeTypes).
- If your endpoint does not take any parameters, then you are now done with this route. However, if your endpoint does have parameters, then for each parameter do the following:Â
- Input the name of the parameter into the "Parameter Name" box and click the "Add Parameter" button (see image below).
- Click on the "+ Empty" link in the "Description" field to add a quick summary about the parameter (see image below).
- WSO2 tries to make a good guess at the other properties of parameter (Parameter Type, Data Type, and Required). However, if you wish to change any of the other options, you can do so by clicking on them (see image below).
- Input the name of the parameter into the "Parameter Name" box and click the "Add Parameter" button (see image below).
- Click on the path name to expand the details of the route (see image below).
- Congratulations! We are finally done with the design step! Now lets move on to the implementation step by clicking the "Next: Implement >" button (see image below).
- You will be presented with the following screen. Choose "Managed API."
- Fill in the section, "Endpoints."
- Select an endpoint type. It is recommended that you select "HTTP Endpoint."Â
- (Required): Type in the Production Endpoint.
- (Optional): Type in the Sandbox Endpoint
- For each Endpoint, click on "Test" (located to the right). The test feature works by checking the root of the endpoint. If nothing exists at the root, it will return "invalid." If the test feature returns "invalid," it will be up to your own discretion whether or not to change the endpoint to something else.
- Click on the "Next: Implement >" button at the bottom of the page (see image below).
- You will be brought to the following screen.
- Fill out the Configurations Section.
- Do NOTÂ check the box "Make this the Default." Checking this box may cause problems down the road for subscribers.
- Select a Tier Availability from the drop-down menu. You may select "unlimited," "gold," "silver," or "bronze." This will determine the frequency at which subscribers will be able to call your API.
- Select HTTPS ONLY as your transport. If you select HTTP, no one will be able to call your API.
- "Transport" refers to the way that the client connects to WSO2, not how WSO2 connects to the backend.
- There are a lot of internal APIs that run on HTTP instead of HTTPS. What you put for your endpoint on the previous page has no bearing on what you select here.
- For more information on Message Mediation, click here.
- Response Caching should be disabled.If you choose to enable response caching, you may run into problems later on.
- Click on "Business Information" to expand the Business Information section.
- Fill out the Business Information Section.Â
- Type in the name of the Business Owner.
- Type in the Business Owner's preferred Email.
- Type in the name of the Technical Owner.
- Type in the Technical Owner's preferred Email.
- For each path, select an authentication type. See the picture below.
- "None" = Unauthenticated. If you select "None," any anonymous user will be able to call your API. Do not select "None" unless there is a very compelling reason to do so. By selecting "None," you sacrifice your ability to monitor the API in WSO2.
- "Application" = Client Credentials authentication.Â
- "Application User" = Authorization Code or Implicit authentication.Â
- "Application & Application User" = Client Credentials, Authorization Code, or Implicit authentication. This is the default setting.
- (Optional): Select a tier for each individual path. This is helpful if you would like a particular path to be throttled differently than the overall API.
- Scroll down to the bottom of the page, and click the button "Save & Publish."
Congratulations! You have successfully published an API to WSO2!