Creating an endpoint
Last updated
Last updated
Click on the + icon next to the search box to create a new endpoint.
You can write your endpoint logic using the Code area. The response of your endpoint will be given by the value you return from your code (the example above always returns the string "hello word").
There are a few options for you to configure:
Endpoint name: This defines the name (and thus the path) of your final endpoint. You can use slashes ('/') to create hierarchy of endpoints (this can be useful for accessing endpoints directly using Endpoint Tokens, which can be scoped to a given endpoint name or path)
Cache Duration: Specifies if the application should cache the result of the computation, and for how long. Set to zero to always run the endpoint code on every call. Caching can be useful for endpoints that perform expensive computations and might be called often by your end-users or external APIs - an example could be an endpoint providing daily aggregates or analytics that have to iterate through a large amount of data.
Access Control: When being called from within the front-end, endpoints can be restricted to either all logged users, or to only admin users.
API style: Curiosity provides two APIs to write your own endpoints - a stable and supported API (i.e. the simplified API in this dropdown), that is very similar to the API exposed by the connector query API. This is the recommended API model to be used for endpoints that do simple queries. For more complex logic, you can use the Advanced API - that provides direct access to lower level APIs.
The methods available in the Advanced API can often change, so make sure to check your endpoints after updating your Curiosity Workspace. You'll see a compilation error warning next to the endpoint name. In doubt, reach out to us to find out how to fix your endpoint if you're missing something.
Once you're done writing your endpoint code, click on Create to deploy it on your application.
Use the Shell to prototype your endpoint, and then convert it to an endpoint.
You can only accept data on your endpoint using the body of the request. This will be available to your endpoint code as a string variable named Body, of which you can use as a string, or deserialize to another type. See the example below on a few ways to use it: