Skip to content
Browse all functions

Filter an Array by an Operator

array/filterarray

filterarray (Filter an Array by an Operator) is a 1001fx API function in the group Arrays: POST https://api.1001fx.com/array/filterarray, 2 credits per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

2 credits per callHTTP APIn8nMake

Filters an array by an given comparison operator.

Try it in the 1001fx app

Run filterarray in your browser with your API key – fill the form, click Run and get the answer or the file.

filterarray in the 1001fx app: the form with example values
Filter an Array by an Operator in the 1001fx app

Endpoint

POSThttps://api.1001fx.com/array/filterarray
Header
X-API-KEY: YOURSECRETAPIKEY How to
Content type
application/json

Parameters

  • dataarray<object>required

    Array of lines with mixed values.

  • queryFieldstringrequired

    Name of the field in data to look for critera. Case sensitive

    Example:
    Column3
  • operatorenumoptional

    Comparison operator. Defaults to eq

    Values:
    eq
    gt
    ge
    lt
    le
    ne
    Default:
    eq
    Example:
    eq
  • criteriastringrequired

    Criteria to look for must be number or string

    Example:
    3
  • ignoreCasebooleanoptional

    Sets case sensitivity for operation.

    Default:
    false
    Example:
    false

Examples

Equal comparison

Rows whose Column3 equals 3; returns 1 row.

Input

Expects a json body
{
  "data": [
    {
      "Column1": "Germany",
      "Column2": "Apple",
      "Column3": 1,
      "Column4": true
    },
    {
      "Column1": "Germany",
      "Column2": "apple",
      "Column3": 2,
      "Column4": true
    },
    {
      "Column1": "US",
      "Column2": "Apple",
      "Column3": 3,
      "Column4": true
    }
  ],
  "queryField": "Column3",
  "operator": "eq",
  "criteria": 3,
  "ignoreCase": false
}

Output · HTTP 200

Response
{
  "result": [
    {
      "Column1": "US",
      "Column2": "Apple",
      "Column3": 3,
      "Column4": true
    }
  ]
}
Show curl command
curl -X POST 'https://api.1001fx.com/array/filterarray' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"Column1":"Germany","Column2":"Apple","Column3":1,"Column4":true},{"Column1":"Germany","Column2":"apple","Column3":2,"Column4":true},{"Column1":"US","Column2":"Apple","Column3":3,"Column4":true}],"queryField":"Column3","operator":"eq","criteria":3,"ignoreCase":false}'

Not equal comparison

Rows whose Column1 is not "us" (ignoring case).

Input

Expects a json body
{
  "data": [
    {
      "Column1": "Germany",
      "Column2": "Apple",
      "Column3": 1,
      "Column4": true
    },
    {
      "Column1": "Germany",
      "Column2": "apple",
      "Column3": 2,
      "Column4": true
    },
    {
      "Column1": "US",
      "Column2": "Apple",
      "Column3": 3,
      "Column4": true
    }
  ],
  "queryField": "Column1",
  "operator": "ne",
  "criteria": "us",
  "ignoreCase": true
}

Output · HTTP 200

Response
{
  "result": [
    {
      "Column1": "Germany",
      "Column2": "Apple",
      "Column3": 1,
      "Column4": true
    },
    {
      "Column1": "Germany",
      "Column2": "apple",
      "Column3": 2,
      "Column4": true
    }
  ]
}
Show curl command
curl -X POST 'https://api.1001fx.com/array/filterarray' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"Column1":"Germany","Column2":"Apple","Column3":1,"Column4":true},{"Column1":"Germany","Column2":"apple","Column3":2,"Column4":true},{"Column1":"US","Column2":"Apple","Column3":3,"Column4":true}],"queryField":"Column1","operator":"ne","criteria":"us","ignoreCase":true}'

Less than comparison

Rows whose Column1 sorts before "US" (ignoring case).

Input

Expects a json body
{
  "data": [
    {
      "Column1": "Germany",
      "Column2": "Apple",
      "Column3": 1,
      "Column4": true
    },
    {
      "Column1": "Germany",
      "Column2": "apple",
      "Column3": 2,
      "Column4": true
    },
    {
      "Column1": "US",
      "Column2": "Apple",
      "Column3": 3,
      "Column4": true
    }
  ],
  "queryField": "Column1",
  "operator": "lt",
  "criteria": "US",
  "ignoreCase": true
}

Output · HTTP 200

Response
{
  "result": [
    {
      "Column1": "Germany",
      "Column2": "Apple",
      "Column3": 1,
      "Column4": true
    },
    {
      "Column1": "Germany",
      "Column2": "apple",
      "Column3": 2,
      "Column4": true
    }
  ]
}
Show curl command
curl -X POST 'https://api.1001fx.com/array/filterarray' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"Column1":"Germany","Column2":"Apple","Column3":1,"Column4":true},{"Column1":"Germany","Column2":"apple","Column3":2,"Column4":true},{"Column1":"US","Column2":"Apple","Column3":3,"Column4":true}],"queryField":"Column1","operator":"lt","criteria":"US","ignoreCase":true}'

Try filterarray now

Run it in your browser or create a free account and get 100 credits every month.

Changelog

  • 1.0.010.03.2023created
Ask 1001fx