Array Utilities

Array Union

Combines two arrays into a single array containing all unique elements from both inputs. Access via MCP in AI coding assistants like Cursor or Windsurf, or call GET /v1/array/union directly. Returns [1,2,3,4,5] when merging [1,2,3] and [3,4,5]. Maintains original data types and removes duplicates deterministically.

API Endpoint

GET /v1/array/union

Code Examples

curl "https://tinyfn.io/v1/array/union" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/union', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/array/union',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's array tools:

{
  "mcpServers": {
    "tinyfn-array": {
      "url": "https://tinyfn.io/mcp/array",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How does array union handle duplicate values?

Removes duplicates automatically, keeping only the first occurrence of each unique value. Order is preserved from the first array, then unique elements from the second.

What data types work with array union in MCP tools?

Supports strings, numbers, booleans, and nested objects. Mixed-type arrays work fine — [1, 'hello', true] unions correctly with other arrays.

Does array union preserve element order?

Yes, maintains order from first array, then appends unique elements from second array in their original sequence.

Can I union arrays with different lengths?

Absolutely. Union works with any array sizes — empty arrays, single elements, or thousands of items. No length restrictions.

How does deep object comparison work in array union?

Objects are compared by reference, not deep equality. Two identical-looking objects {id: 1} are treated as different unless they're the same reference.

Try Array Union Now

Get your free API key and start using Array Union in seconds.

Get Free API Key