Hello World Example
This guide will walk you through creating an API file and a basic Get REST API endpoint that will return the a Hello World message.
Open the workspaceÂ
(If you haven't created an example workspace, create a workspace called papihello. See Using Workspaces)Â
Open the example workspace by pointing your browser to the URL:
http://[HOST]:[PORT]/ide/papihello
Where host is the server you installed Profound.js on and port is the port number Profound.js is running on. If the installation is on your PC or Mac computer, use localhost.
OR open the workspace from the ide with the Open button and then select the example workspace:
Create API file
Create a new API json file by clicking the New button and selecting API file. The file will be opened and the Canvas, Parameters, API Routes, and Properties panel will be initialized.
Â
        ÂSet Properties
On the left hand lower panel select the General Info tab and fill on the following values
- Name: hello
- Summary: hello world example
HTTP Method: get
HTTP Path: /helloworld
- Category, Sub Category, Tag, and Description all help improve documentation and organization.Â
Output Parameters
In the lower center panel select the Output Parameters tab.Â
Click the green plus button to add a new parameter. This will open the API Parameter dialog.
Enter Response for the name and leave the Data type set to string. Adding an example and description helps the auto-generated documentation be more complete.Â
Click OK to add the parameter.
Save
Save your API file by clicking the Save button in the menu ribbon. The first time you use save you will be presented a save dialog with the File Name defaulting to Unnamed.api.json. You should change the Unnamed portion to an appropriate file name, like helloworld.api.json in this case. Click Save.
Add Logic
It is best to add properties and parameters and then save before starting on logic steps because the parameters will appear as options when building the logic steps.
Profound API uses Low Code steps to build the logic of the API. In this example we have one step to set the output to the "Hello World" message.
Click on Add Step... in the canvas.
The step builder dialog will open. At the top type a description for the step then in the What would you like to do? drop down scroll down and click on Program Data. From the Program Data options click on Set API Output.Â
The dialog will update to allow you to specify the value for the response parameter. For this example we will return a static string value so enter the value 'Hello World' for the parameter. Then click OK.
Save
Save the changes
Test
On the lower right panel switch to the Test tab. If the API endpoint expected parameters there would be options to enter them at the top of the Test panel.
For this example, there are no parameters so just click Execute to test the endpoint.
After running the test the panel will update with several responses.
- Curl - This box will present the Curl command that can be run to consume the REST endpoint
- Request URL - the URL of the request. In the case of a GET request this URL can be copied and pasted into the Address bar of your browser to test the endpoint directly from the browser.
- Server response - The server response section includes the HTTP code returned as well as the Response body and headers.Â
- Response body - In this case the response body includes our parameter with the Hello World message.
- Response headers - includes all of the headers returned from the server Â
- The Response section shows what response types should be expected including any default values that were defined in the parameters.
Live Test
The API endpoints are live as soon as they are saved. As mentioned above, for a simple GET endpoint you can test the endpoint in your browser by copying the Request URL and pasting it in your browser address bar.
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!