Array Utilities

Array Slice

Extract portions of arrays with precise start/end indices using TinyFn's slice tool. Available via MCP in Cursor and other AI coding assistants, or REST at GET /v1/array/slice. Returns ["b", "c"] from ["a", "b", "c", "d"] with start=1, end=3. Handles negative indices and boundary cases deterministically.

API Endpoint

GET /v1/array/slice

Code Examples

curl "https://tinyfn.io/v1/array/slice" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/slice', {
  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/slice',
    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 slice an array with TinyFn?

Send array data with start and optional end indices to GET /v1/array/slice. Start is inclusive, end is exclusive (like Python/JavaScript slice).

Can I use negative indices when slicing arrays?

Yes, negative indices count from the end of the array. Index -1 refers to the last element, -2 to second-to-last, etc.

What happens if slice indices are out of bounds?

TinyFn handles boundary cases gracefully - indices beyond array length are clamped to valid ranges, preventing errors.

How can MCP agents use array slicing in code generation?

AI coding assistants can slice arrays for data processing, pagination logic, or extracting subsets without writing custom loop code.

What's the difference between TinyFn slice and native language slicing?

TinyFn provides consistent slice behavior across different programming contexts and guaranteed deterministic results for AI agents.

Try Array Slice Now

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

Get Free API Key