Curiosity for Developers
  • Overview
  • Getting Started
    • Introduction
    • System Overview
      • Workspace
      • Connectors
      • Front End
    • Requirements
    • Installation
      • Deploying on Windows
        • Download Curiosity Workspace for Windows
      • Deploying on Docker
        • Deploying using Docker Desktop App
        • Docker Hub
      • Deploying on Kubernetes
      • Deploying on OpenShift
      • Configuration
    • Configure your Workspace
    • Connecting to a Workspace
      • Download App
    • Built-in Templates
  • Security
    • Introduction
    • Hosting
    • Encryption
    • Users and Access
      • User Invitations
      • Single Sign-On (SSO)
        • Google Sign-In
        • Microsoft / Azure AD
        • Okta
        • Auth0
    • Permissions Management
    • Auditing
    • Teams management
    • Configuring Backup
      • Restoring a backup
    • Activate a workspace license
  • Data Sources
    • Introduction
    • User Apps
    • Workspace Integrations
    • API Integrations
      • Introduction
      • Data Modeling
      • Writing a Connector
      • Access Control
      • API Tokens
      • API Overview
      • Tips
    • Supported File Types
    • Curiosity CLI
      • Installation
      • Authentication
      • Commands
  • Search
    • Introduction
    • Languages
    • Synonyms
    • Ranking
    • Filters
    • Search Permissions and Access Control
  • Endpoints
    • Introduction
    • Creating an endpoint
    • Calling an endpoint
    • Endpoint Tokens
    • Endpoints API
  • Interfaces
    • Introduction
    • Local Development
    • Deploying a new interface
    • Routing
    • Node Renderers
    • Sidebar
    • Views
  • Artificial Intelligence
    • Introduction
    • Embeddings Search
    • AI Assistant
      • Enabling AI Assistant
    • Large Language Models
      • LLMs Models Configuration
      • Self-Hosted Models
    • Image Search
    • Audio and Video Search
  • Sample Workspaces
    • Introduction
    • HackerNews
    • Aviation Incidents
    • Covid Papers
    • NASA Public Library
    • Suggest a Recipe
  • Basic Concepts
    • Graph database
    • Search Engine
  • Troubleshooting
    • FAQs
      • How long does it take to set up?
      • How does Curiosity keep my data safe?
      • Can we get Curiosity on-premises?
      • Can I connect custom data?
      • How does Workspace pricing work?
      • Which LLM does Curiosity use?
      • What's special about Curiosity?
      • How are access permissions handled?
      • What enterprise tools can I connect?
      • How to access a workspace?
      • How do I hard refresh my browser?
      • How do I report bugs?
      • How do I solve connectivity issues?
      • How do I contact support?
  • Policies
    • Terms of Service
    • Privacy Policy
Powered by GitBook
On this page
  • From within the user interface
  • From data connectors
  • From outside the workspace
  1. Endpoints

Calling an endpoint

There are three ways of calling a custom endpoint in Curiosity Workspace: one from within the user interface, one from within a data connector, and finally one for external callers.

From within the user interface

The first way is to use the endpoint API that is provided as part of the Curiosity front-end package, which takes care of configuring the HTTP request, data serialization, authorization and the asynchronous endpoint processing logic.

Existing endpoints can be invoked from front-end code using the following syntax:

// Calls an endpoint without any body:
var response = await Mosaik.API.Endpoints.CallAsync<string>("hello");

// Calls an endpoint with an object as body:

public class RequestData 
{
    public DateTimeOffset From { get; set; }
    public DateTimeOffset To   { get; set; }
}

var requestData = new RequestData() 
{ 
    From = DateTimeOffset.UtcNow.AddDays(-30), 
    To   = DateTimeOffset.UtcNow,
};

var response = await Mosaik.API.Endpoints.CallAsync<string>("hello", requestData);

From data connectors

The data connector package provides a helper class that wraps the logic of calling an endpoint for you. You can use this class as following:

var endpointClient = new EndpointsClient("url-to-server", "endpoint-token");

var stringResponse = await endpointClient.CallAsync("hello");
var objectResponse = await endpointClient.CallAsync<ResponseType>("hello");

//You can also call the endpoint with some content:

var requestData = new RequestData() 
{ 
    From = DateTimeOffset.UtcNow.AddDays(-30), 
    To   = DateTimeOffset.UtcNow,
};

await endpointClient.CallAsync<RequestData>("hello", requestData);
var response = await endpointClient.CallAsync<RequestData, string>("hello", requestData);

From outside the workspace

The final way is to use any HTTP client or tool that can send requests over HTTPS, such as curl or Postman. In this case you'll need to generate a valid endpoint token, and you need to provide it as a Bearer token in the Authentication header. For example, you can call an endpoint using curl:

# POST to: http://localhost:5001/api/cce/token/run/hello

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" --data "${BODY}" <http://localhost:5001/api/cce/token/run/hello>

When calling an endpoint, you must check the Status Code of the response, as endpoints run asynchronously by default, and will return 202 Accepted if the call was received but the result is not yet available. If you receive a 202 response, you should call again the same endpoint with the exact same request (i.e. same body) until you receive a 200 (in case of success) or 500 (in case of failure) response.

When you call an endpoint from the front-end or the connector, the helper methods will take care of this retry logic for you

PreviousCreating an endpointNextEndpoint Tokens

Last updated 2 years ago