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

Custom Endpoints

In addition to generating CRUD (Create, Read, Update, Delete), authentication, and file management endpoints, Twidget allows you to create completely custom endpoints from scratch. These custom endpoints give you full control over the various aspects of endpoint configuration, including the inputs, ...

Generate CRUD Endpoints

What are CRUD Endpoints?. CRUD stands for Create, Read, Update, Delete. These are the basic operations required to manage data in a database. Each operation corresponds to a specific HTTP method: - Create: Adds new data (HTTP POST) - Read: Retrieves data (HTTP GET) - Update: Modifies existing data (...

What is an API

An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate and interact with each other. It defines the methods and data formats that applications can use to request and exchange information, services, or functionalities from...

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...

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...