Skip to main content
GET
/
api
/
users
/
search
/
{
  "count": 123,
  "users": [
    {
      "auth0_user_id": "<string>",
      "name": "<string>",
      "image_url": "<string>",
      "date_registered": "<string>",
      "email": "<string>",
      "home_address": "<string>",
      "home_coords": "<string>",
      "work_address": "<string>",
      "work_coords": "<string>"
    }
  ]
}

Overview

Search for CycleMate users by name. Requires a minimum of 3 characters for the search query. Returns non-PII user profiles for regular users, or full profiles for admin users.

Authentication

Required: This endpoint requires Auth0 authentication. Include a valid JWT token in the Authorization header.

Query Parameters

q
string
required
Search query for user name (minimum 3 characters, case-insensitive)

Response

Returns an object with a count and array of matching users:
count
number
Total number of users matching the search query (max 50 results)
users
array
Array of user profile objects matching the search query

Request Example

cURL
curl "https://api.cyclemate.com/api/users/search/?q=John" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
JavaScript
const response = await fetch(
  'https://api.cyclemate.com/api/users/search/?q=John',
  {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${yourJwtToken}`,
    },
  }
);

const data = await response.json();
console.log(`Found ${data.count} users`);
console.log(data.users);
Python
import requests

url = "https://api.cyclemate.com/api/users/search/"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {your_jwt_token}"
}
params = {"q": "John"}

response = requests.get(url, headers=headers, params=params)
data = response.json()
print(f"Found {data['count']} users")

Response Example

Regular User Response

{
  "count": 2,
  "users": [
    {
      "auth0_user_id": "google-oauth2|115315991711634062214",
      "name": "John Doe",
      "image_url": "https://storage.googleapis.com/users/profile-123.jpg",
      "date_registered": "2025-01-15T10:30:00Z"
    },
    {
      "auth0_user_id": "auth0|67890abcdef",
      "name": "Johnny Smith",
      "image_url": null,
      "date_registered": "2025-03-20T14:45:00Z"
    }
  ]
}

Admin User Response

Admin users receive additional PII fields:
{
  "count": 2,
  "users": [
    {
      "auth0_user_id": "google-oauth2|115315991711634062214",
      "email": "john.doe@example.com",
      "name": "John Doe",
      "image_url": "https://storage.googleapis.com/users/profile-123.jpg",
      "home_address": "123 Main St, San Francisco, CA",
      "home_coords": "-122.4194,37.7749",
      "work_address": "456 Market St, San Francisco, CA",
      "work_coords": "-122.3986,37.7893",
      "date_registered": "2025-01-15T10:30:00Z"
    },
    {
      "auth0_user_id": "auth0|67890abcdef",
      "email": "johnny.smith@example.com",
      "name": "Johnny Smith",
      "image_url": null,
      "home_address": null,
      "home_coords": null,
      "work_address": null,
      "work_coords": null,
      "date_registered": "2025-03-20T14:45:00Z"
    }
  ]
}

Error Responses

Query Too Short (400)

{
  "error": "Search query must be at least 3 characters"
}

Unauthorized (401)

{
  "error": "Authentication credentials were not provided."
}

Notes

  • Minimum Query Length: Search query must be at least 3 characters
  • Case-Insensitive: Search is case-insensitive (searching “john” will match “John”, “JOHN”, etc.)
  • Partial Matching: Search matches partial names (searching “John” will match “Johnny”, “Johnson”, etc.)
  • Result Limit: Returns maximum 50 results
  • Privacy: Regular users only see public profile information (no email or address data)
  • Admin Access: Admin users see full profile information including email and addresses

Use Cases

  • Event Management: Find users to assign as event owners
  • User Discovery: Help users find and connect with other cyclists
  • Admin Operations: Search for users to manage accounts or resolve issues
  • Community Features: Enable user mentions, tagging, or invitations