Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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:

Image ModifiedImage Modified


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.

Image Modified    Image Added            

...

  Image Modified

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. 

Image Modified

Output Parameters

In the lower center panel select the Output Parameters tab. 

Image Added

Click the green plus button to add a new parameter. This will open the API Parameter dialog.

Save

...

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. 

Image Added

Click OK to add the parameter.

Image Added

Save

Save your API file by clicking the Save button in the menu ribbon. Image Added 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.


Image Modified


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.

Image Added

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

Image Added

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.

Image Added

Save

Save the changes Image Added

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.

Image Added

For this example, there are no parameters so just click Execute to test the endpoint.

Section


Column

Image Added

After running the test the panel will update with several responses.

  1. Curl - This box will present the Curl command that can be run to consume the REST endpoint
  2. 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.
  3. Server response - The server response section includes the HTTP code returned as well as the Response body and headers. 
  4. Response body - In this case the response body includes our parameter with the Hello World message.
  5. Response headers - includes all of the headers returned from the server  
  6. 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.

Image Added