Skip to main content

API Endpoints

This section explains how to consume data generated in a Pyplan app from outside of Pyplan.

Creating an API Endpoint

To create an API endpoint, you need to create a node whose result is a Python function that can optionally receive parameters.

API Function Node

If the function must return a value, it should be in JSON format. For example:

def _fn(name1, name2):
data = {
'Name': [name1, name2, 'Alice', 'Bob'],
'Age': [25, 30, 35, 40],
'City': ['New York', 'Los Angeles', 'Chicago', 'Houston']
}
df = pd.DataFrame(data)
return df.to_json(orient="index")

result = _fn

Then, right-click on the created node and choose the Get API Endpoint option:

Get API Endpoint Menu

The following window will be displayed:

Get API Endpoint Window

The Share instance option allows multiple calls to the API endpoint to be served from the same instance without creating a new one for each call.

caution

API endpoints are only available for the Default version of the app.

Structure of the API Endpoint Call

  • HTTP method: POST
  • Content-Type: application/json
  • Headers (optional): If the endpoint has an assigned API key, send it as the x-api-key parameter.
  • Body (optional): form-data. Where the parameters to feed the function are sent.

Example using Postman:

Postman Example

API Endpoints Manager

In the API endpoints section, you can edit and delete the created API endpoints of the current application.

API Endpoint Manager Option

External Links Manager

To edit an API endpoint, select it and click the Edit button.

External Link Edit

The available options are:

External Link Edit Window

OptionDescription
Common instanceAllows enabling/disabling sharing of the instance when making multiple calls.
ActiveAllows enabling/disabling the API endpoint completely.
Custom endpointAllows assigning a custom name to the external link endpoint.
ExecutorAllows choosing which user will open the instance.
API keyAllows selecting a previously created key to send as a x-api-key header.

To delete an API endpoint, click the delete icon.

External Link Delete

API Key Manager

To create, edit, or delete API keys, click the Show API keys button:

Show API Keys

To create a new API key, click Create API key:

Create API Key

Create API Key Window

OptionDescription
ActiveAllows enabling/disabling the API key.
AliasAllows assigning a personalized name to the API key for easier recognition.
KeyThe actual API key. It can be edited with a custom value. Save this key securely — it cannot be viewed again after creation, only replaced or deleted.

To edit an API key, select it and click Edit API key:

Edit API Key

To delete an API key, click the delete icon:

Delete API Key

To assign an API key to an API endpoint, edit the API endpoint and select the desired API key:

Select API Key