Skip to main content

Mock implementation of the Happenstance API for generating synthetic relationship-intelligence data

Project description

mock-happenstance-api

This is a public-source project — see CONTRIBUTING.md for the PR policy.

A deterministic, self-hosted mock of the Happenstance relationship-intelligence API — same endpoints, request/response shapes, and async job-polling behavior as the real API, backed by a synthetic VC/startup-flavored people graph instead of real data.

Built for projects that need a Happenstance connector but have no access to (or need for) the real, paid API while developing.

Quickstart

uv sync
make seed   # generates happenstance.db from a fixed seed
make dev    # serves the API on http://localhost:8000
curl -s http://localhost:8000/v1/search -H "Authorization: Bearer test" \
  -H "Content-Type: application/json" \
  -d '{"text": "biotech founders in Boston"}'

Any non-empty bearer token is accepted — there's no real key management.

Endpoints

POST /v1/search, GET /v1/search/{id}, POST /v1/search/{id}/find-more, POST /v1/research, GET /v1/research/{id}, GET /v1/users/me, GET /v1/usage, GET /v1/groups, GET /v1/groups/{id} — mirroring the real API's shape (see developer.happenstance.ai).

Data model

make seed deterministically generates ~300-500 synthetic people, ~40-60 companies, and ~15-20 co-investor groups, all connected by a real graph of colleague/connection/co-investor/advisor/board edges. Search, mutuals, @mention filtering, and warm-intro paths all read from that graph rather than being randomized per call.

Testing error paths

  • X-Mock-Force-Status: 402 or 429 header forces that error on any request.
  • A research description containing __FAIL__ or __FAIL_AMBIGUOUS__ forces that terminal research status.
  • HAPPENSTANCE_MOCK_DELAY=realistic (env var) simulates the real API's 30-60s (search) / 1-3min (research) RUNNINGCOMPLETED delay instead of completing instantly.

Development

make test       # pytest
make lint       # ruff + pyright

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mock_happenstance_api-0.1.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mock_happenstance_api-0.1.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file mock_happenstance_api-0.1.0.tar.gz.

File metadata

File hashes

Hashes for mock_happenstance_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 33278040571ecffc38258206b4195405eb52b45f185af3f40021319c08e8ff2d
MD5 55e57137ea53669aa86d6d16a1c38c54
BLAKE2b-256 34cd918e8c76e587d25172c65c3f09edb4ff37de9001e6ee6fc75ac626a2fbcb

See more details on using hashes here.

File details

Details for the file mock_happenstance_api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mock_happenstance_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f7a1af6e62adcefb8d2ae1094f60750e2027e4dc5dc4d31e06a9feab7b4338d
MD5 737bb385f871b193ed21b4bc155ef7e2
BLAKE2b-256 e9548d63a62004b89afa3761e763c1ce25d0bc3266bd240141cb5590f75c3d87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page