Sign Up

Endpoint Inputs

In Twidget, endpoints have a variety of input types that can be used to configure and execute API requests. These input types include queries, headers, body, files, and path inputs. Each input type serves a specific purpose in allowing users to interact with APIs efficiently.

-

Files

The files input type allows users to upload files to the server, which can then be stored in the filestore. You can upload multiple files simultaneously using this input type, making it flexible for file-heavy applications.

  • Usage: Files are referenced within commands using the $files. prefix.

  • Example: $files.file1

Files are uploaded as multipart form data, and you can access them within your commands or logic flows.

Queries

Queries are key-value pairs typically used in the URL of an API request. They allow you to pass lightweight data to the server via the query string. This is often used for filtering, sorting, or pagination purposes in API requests.

  • Usage: Queries are referenced using the $queries. prefix.

  • Example: $queries.pageNumber

Queries are passed in the URL like this: ?pageNumber=2&sortBy=name. In the platform, you can dynamically set these values and use them to influence the behavior of your API calls.

Headers

Headers are another form of key-value pairs that are sent in the HTTP header. They provide metadata about the request or the client, like authorization tokens, content type, and more.

  • Usage: Headers are referenced using the $headers. prefix.

  • Example: $headers.Authorization

Headers are critical in handling authentication and determining the format of the data exchanged (like JSON or XML). You can configure headers dynamically to interact with secured APIs or send custom information in your request.

Body

The body input type is used for more complex inputs like JSON objects. This is the part of the request that sends the main data payload, typically for POST, PUT, or PATCH requests.

  • Usage: The body inputs are referenced using the $body. prefix.

  • Example: $body.userData


{

    "name": "John Doe",

    "email": "john@example.com"

}

The body is useful when you need to send structured data like JSON or XML. For example, when submitting a form or creating a resource on the server.

Path

Path inputs are special variables that are embedded within the endpoint's URL path. These variables are defined by enclosing them in curly braces ({}). They allow for dynamic values to be substituted into the URL.

  • Usage: Path inputs are referenced using the $path. prefix.

  • Example: $path.field

For example, consider the following endpoint URL: /users/{userId}/posts. Here, {userId} is a path input. When making the request, the userId will be dynamically populated based on the value provided.

Summary of Endpoint Input Usage

To use endpoint inputs within commands or logic flows, you can reference them using the following patterns:

  • Files: $files.<fileName>

  • Queries: $queries.<key>

  • Headers: $headers.<key>

  • Body: $body.<field>

  • Path: $path.<variable>

This system provides flexibility in how you manage API requests, allowing you to handle a wide variety of input types and use them effectively within the platform.

Related Topics

Endpoint Basics

An endpoint refers to a specific URL (Uniform Resource Locator) that a client can access to interact with the API and perform various operations. Endpoints act as gateways that allow clients (such as web or mobile applications) to communicate with the server hosting the API and perform actions like ...

Creating Authentication Endpoints

Follow these steps to create authentication endpoints in Twidget: Step-by-Step Guide. 1. Navigate to API Tab: - Go to the `API` tab in your Twidget dashboard. 2. Create New Endpoints: - Click on the `Create Endpoints` button located at the top right corner. 3. Select Authentication: - In the newly o...

Create File Endpoints

Overview. Twidget allows you to create file endpoints, which enable you to manage files in your file store. This feature is designed to streamline your workflow by providing predefined endpoints for common file operations. Creating File Endpoints. To create a file endpoint in Twidget, follow these s...

Authentication

Twidget supports Bearer Authentication to ensure secure access to your endpoints. You can specify which endpoints should be secured or open. Once secured, an endpoint can only be accessed using a valid Bearer Token, which is generated via our API. Additionally, we provide functionality to generate a...

API Settings

The API settings in Twidget enable you to customize your APIs to fit your requirements. Here’s how you can do it: Configure. 1. Navigate to the API page. 2. Click on the Settings button located at the top-right corner. This will open a sidebar where you can configure various settings for your API. A...