GET/api/players/search

Search for players by name with fuzzy matching support.

Query Parameters

ParameterTypeDescriptionRequired
qstringSearch query (player name)Yes
teamTypecurr | class | alltFilter by team typeNo
limitnumberMaximum results to return (max 50)No (default: 50)

Example Request

const response = await fetch(
  'https://api.nba2kapi.com/api/players/search?q=lebron',
  {
    headers: {
      'X-API-Key': 'your_api_key_here'
    }
  }
);

const data = await response.json();
console.log(data.data); // Array of matching players

Example Response

{
  "success": true,
  "data": [
    {
      "_id": "abc123",
      "name": "LeBron James",
      "slug": "lebron-james",
      "team": "Los Angeles Lakers",
      "teamType": "curr",
      "overall": 97,
      "positions": ["SF", "PF"],
      "playerImage": "https://...",
      "teamImg": "https://..."
    }
  ],
  "meta": {
    "count": 1,
    "total": 1,
    "truncated": false,
    "timestamp": "2025-01-15T00:00:00.000Z"
  }
}

Search Tips

Partial Matching

Search works with partial names. You don't need to type the full name.

// All of these will find LeBron James:
?q=lebron
?q=lebron james
?q=leb
?q=james lebron

Case Insensitive

Search is case-insensitive. ?q=LEBRON and ?q=lebron return the same results.

Combine with Filters

Narrow results by combining search with team type filters.

// Search only current rosters
?q=michael jordan&teamType=curr

// Search classic teams
?q=kobe&teamType=class

Common Use Cases

  • • Building an autocomplete search box
  • • Finding players by last name
  • • Implementing a "type to search" feature
  • • Creating Discord bot commands (/player search lebron)