Array Utilities

Array First

Extracts the first n elements from any array through GET /v1/array/first. Pass your array and count parameter to get a clean subset without array slicing complexity. Works with strings, numbers, objects — any data type. Essential for pagination, preview generation, and data sampling in MCP-enabled editors like Cursor and Windsurf.

API Endpoint

GET /v1/array/first

Code Examples

curl "https://tinyfn.io/v1/array/first" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/first', {
  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/first',
    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 do I get the first 3 items from an array using TinyFn?

Send GET request to /v1/array/first with your array and n=3 parameter. Returns a new array containing exactly the first 3 elements.

What happens if I request more items than the array contains?

The function returns all available items without errors. If your array has 5 items and you request first 10, you get all 5.

Can Array First handle mixed data types in the same array?

Yes, it preserves all data types exactly as provided — strings, numbers, objects, nested arrays, booleans, and null values.

How does this compare to JavaScript array.slice(0, n)?

Functionally identical but available as a deterministic API call. Useful when you need consistent results across different environments or in MCP agents.

Can I use Array First in Cursor for code generation tasks?

Absolutely. MCP integration lets Cursor call this function directly when processing arrays, ensuring reliable subset extraction without hallucinated slice operations.

Try Array First Now

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

Get Free API Key