Skip to main content

Prerequisites

Before you begin, make sure you have:
  • A Happenstance account
  • Your API key (generated from Settings)

Make Your First Request

1. Submit a Search Request

Search for relevant people within your groups and connections:
curl -X POST https://api.happenstance.ai/v1/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "engineers who have worked on AI infrastructure",
    "include_my_connections": true
  }'
Response:
{
  "id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "url": "https://happenstance.ai/search/a1b2c3d4-5678-90ab-cdef-1234567890ab"
}
You can also search within specific groups by including group_ids - get your group IDs from the /v1/groups endpoint.
Use @mentions in your query to filter results to a specific person’s connections. For example: "engineers @Jane Smith knows". Use the /v1/groups/{group_id} endpoint to look up member names.

2. Poll for Results

Search runs asynchronously. Poll the GET endpoint until status is COMPLETED:
curl -X GET https://api.happenstance.ai/v1/search/a1b2c3d4-5678-90ab-cdef-1234567890ab \
  -H "Authorization: Bearer YOUR_API_KEY"
Response (in progress):
{
  "id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "url": "https://happenstance.ai/search/a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "status": "RUNNING",
  "text": "engineers who have worked on AI infrastructure",
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T10:30:05Z",
  "results": null
}
Response (completed):
{
  "id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "url": "https://happenstance.ai/search/a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "status": "COMPLETED",
  "text": "engineers who have worked on AI infrastructure",
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T10:30:45Z",
  "results": [
    {
      "id": "person-uuid-1",
      "name": "Jane Smith",
      "current_title": "Staff Engineer",
      "current_company": "OpenAI",
      "summary": "Led infrastructure team building distributed training systems...",
      "weighted_traits_score": 2.5,
      "socials": {
        "happenstance_url": "https://happenstance.ai/u/person-uuid-1",
        "linkedin_url": "https://linkedin.com/in/janesmith"
      }
    }
  ],
  "has_more": true
}
Poll every 5-10 seconds. Search typically completes within 30-60 seconds.

3. Find More Results (Optional)

If has_more is true, you can request additional results:
curl -X POST https://api.happenstance.ai/v1/search/a1b2c3d4-5678-90ab-cdef-1234567890ab/find-more \
  -H "Authorization: Bearer YOUR_API_KEY"

Next Steps