> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FTP List Connector

> You can perform file and directory listing operations using FTP connection definitions and create API Proxies. You can list files in the defined directory in your FTP connection and create API Proxies that return the result of this listing operation with advanced filtering and search capabilities.

<img src="https://mintcdn.com/apinizer/-OUVpYz7x56LFQ3F/images/yonetici/konnektor/ftp-list.png?fit=max&auto=format&n=-OUVpYz7x56LFQ3F&q=85&s=f498e32399b18a129b7060bdac69176f" alt="FTP List Connector Configuration" width="800" className="mr-auto" data-path="images/yonetici/konnektor/ftp-list.png" />

## Usage

FTP List connector is used to list files and directories on FTP server. The created connector works as an API Proxy and can be triggered with either HTTP GET or POST request. When using POST request, you can apply advanced filtering criteria to search and filter files.

### Basic Usage (GET Request)

You can retrieve all files in the directory with a simple GET request:

```bash theme={null}
curl --location --request GET "https://<APINIZER_ACCESS_URL>/<RELATIVE_PATH>"
```

### Advanced Usage (POST Request)

You can apply filtering criteria by sending request body with POST request:

```bash theme={null}
curl --location --request POST "https://<APINIZER_ACCESS_URL>/<RELATIVE_PATH>" \
  -H "Content-Type: application/json" \
  --data-raw '{"searchType": "WILDCARD", "searchPattern": "*.json", "caseInsensitive": true}'
```

<Info>
  When request body is sent empty or GET request is made, all files in the directory are listed with default values.
</Info>

## Request Body Parameters

<AccordionGroup>
  <Accordion title="File Search Settings">
    <CardGroup cols={2}>
      <Card title="searchType" icon="magnifying-glass">
        **Type:** string

        **Default Value:** STARTS\_WITH

        **Description:** Specifies how file names will be searched. Available options:

        * **STARTS\_WITH**: Checks if file name starts with the given pattern
        * **EXACT\_MATCH**: Checks for exact match with the given file name
        * **CONTAINS**: Checks if file name contains the given pattern
        * **ENDS\_WITH**: Checks if file name ends with the given pattern
        * **WILDCARD**: Uses wildcard pattern matching (\* matches any sequence, ? matches single character)
      </Card>

      <Card title="searchPattern" icon="filter">
        **Type:** string

        **Default Value:** (empty - lists all files)

        **Description:** File name or pattern to search for. Usage depends on searchType:

        * For WILDCARD: `*.json`, `file?.txt`, `report_*.pdf`
        * For ENDS\_WITH: `.json`, `.pdf`
        * For STARTS\_WITH: `invoice_`, `report`
        * For CONTAINS: `2025`, `data`
        * For EXACT\_MATCH: `report.pdf`, `data.json`
      </Card>

      <Card title="caseInsensitive" icon="font">
        **Type:** boolean

        **Default Value:** true

        **Description:** Determines whether file name search is case-sensitive. When set to true, "File.txt" and "file.txt" are treated as the same.
      </Card>

      <Card title="returnType" icon="list">
        **Type:** string

        **Default Value:** ALL\_MATCHES

        **Description:** Specifies the amount of results to return:

        * **FIRST\_MATCH**: Returns only the first matching file and stops searching
        * **ALL\_MATCHES**: Returns all matching files
      </Card>
    </CardGroup>
  </Accordion>

  <Accordion title="File Size Limitation">
    <Card title="maxFileSizeKB" icon="gauge">
      **Type:** integer

      **Default Value:** (no limit)

      **Description:** Maximum file size in kilobytes (KB). Files larger than this size are excluded from results. For example, setting it to 10240 means only files up to 10 MB are included.

      **Note:** This parameter only affects file size filtering in listing results. It does not limit the file reading operation.
    </Card>
  </Accordion>
</AccordionGroup>

## Response Format

The response is returned in JSON or XML format based on the Accept header in the request.

### Successful Response (Files Found)

```json theme={null}
{
  "files": [
    "invoice_2025_001.pdf",
    "invoice_2025_002.pdf",
    "report.json"
  ],
  "count": 3,
  "searchType": "starts_with",
  "caseInsensitive": true,
  "returnType": "all_matches"
}
```

### Empty Response (No Files Found)

```json theme={null}
{
  "files": [],
  "count": 0,
  "message": "No files matching pattern '*.xml'",
  "searchType": "wildcard",
  "caseInsensitive": true,
  "returnType": "all_matches"
}
```

<Info>
  When no files are found, the `message` field provides information about why no results were returned.
</Info>

## Example Scenarios

### Example 1: List All JSON Files

**Usage Scenario**: Find all files with .json extension in the directory

```json theme={null}
{
  "searchType": "WILDCARD",
  "searchPattern": "*.json",
  "caseInsensitive": true
}
```

**Response:**

```json theme={null}
{
  "files": ["data.json", "config.json", "report.json"],
  "count": 3,
  "message": null
}
```

### Example 2: Find Files Starting with "invoice"

**Usage Scenario**: List all files starting with "invoice" prefix

```json theme={null}
{
  "searchType": "STARTS_WITH",
  "searchPattern": "invoice",
  "caseInsensitive": false,
  "returnType": "ALL_MATCHES"
}
```

### Example 3: Find First PDF File

**Usage Scenario**: Get only the first PDF file and stop searching

```json theme={null}
{
  "searchType": "ENDS_WITH",
  "searchPattern": ".pdf",
  "returnType": "FIRST_MATCH"
}
```

**Response:**

```json theme={null}
{
  "files": ["report.pdf"],
  "count": 1
}
```

### Example 4: Exact File Name Match

**Usage Scenario**: Check if a specific file exists

```json theme={null}
{
  "searchType": "EXACT_MATCH",
  "searchPattern": "config.json"
}
```

### Example 5: Wildcard with Multiple Patterns

**Usage Scenario**: Find files matching complex patterns

```json theme={null}
{
  "searchType": "WILDCARD",
  "searchPattern": "report_2025_??.pdf"
}
```

This will match files like `report_2025_01.pdf`, `report_2025_12.pdf` but not `report_2025_123.pdf`

## Response Content Type

The connector returns response based on the Accept header:

* **application/json** (default): Returns response in JSON format
* **application/xml**: Returns response in XML format

Example with XML request:

```bash theme={null}
curl --location --request POST "https://<APINIZER_ACCESS_URL>/<RELATIVE_PATH>" \
  -H "Accept: application/xml" \
  -H "Content-Type: application/json" \
  --data-raw '{"searchPattern": "*.json"}'
```
