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.
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)
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"
}
}
}
}
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.
Supports strings, numbers, booleans, and nested objects. Mixed-type arrays work fine — [1, 'hello', true] unions correctly with other arrays.
Yes, maintains order from first array, then appends unique elements from second array in their original sequence.
Absolutely. Union works with any array sizes — empty arrays, single elements, or thousands of items. No length restrictions.
Objects are compared by reference, not deep equality. Two identical-looking objects {id: 1} are treated as different unless they're the same reference.