GET
/api/players/searchSearch for players by name with fuzzy matching support.
Query Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| q | string | Search query (player name) | Yes |
| teamType | curr | class | allt | Filter by team type | No |
| limit | number | Maximum 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 playersExample 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 lebronCase 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=classCommon 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)