Python SDK for the Semantik Client API
Project description
Semantik Python SDK
Python SDK for the Semantik Client API. Designed for Python 3.8+ applications.
Installation
Prerequisites
Install uv (fast Python package manager):
curl -LsSf https://astral.sh/uv/install.sh | sh
# or
brew install uv
# or
pip install uv
Option 1: Local Development (Current)
Since the package is not yet published to PyPI, install it locally:
cd semantik-sdk/python
uv pip install -e .
Or install from the repository root:
uv pip install -e semantik-sdk/python
Option 2: From Git Repository
If the repository is accessible via Git:
uv pip install git+https://github.com/your-org/semantik.git#subdirectory=semantik-sdk/python
Option 3: Published Package (Future)
Once published to PyPI:
uv pip install semantik-sdk
# or with uv's native support (when available)
uv add semantik-sdk
Quick Start
from semantik import Semantik
import base64
# Option 1: Automatically reads from SEMANTIK_API_KEY environment variable (recommended)
# Set SEMANTIK_API_KEY in your .env file or environment
client = Semantik()
# Option 2: Override with explicit API key
client = Semantik(api_key="sk_your_api_key_here")
# List programs
programs_response = client.programs.list()
print(f"Found {len(programs_response['programs'])} programs")
# Get a specific program
program = client.programs.get(programs_response['programs'][0]['id'])
# Submit a candidate application
with open('resume.pdf', 'rb') as f:
cv_content = base64.b64encode(f.read()).decode('utf-8')
result = client.candidates.submit_application(
candidate={
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com"
},
program_id=program['id'],
step_id=program['steps'][0]['id'],
documents=[
{
"fieldName": "CV",
"content": cv_content,
"fileName": "john-doe-cv.pdf",
"mimeType": "application/pdf",
"encoding": "base64"
}
]
)
print(f"Application submitted: {result['applicationId']}")
print(f"Candidate ID: {result['candidateId']}")
# Get candidate status
status = client.candidates.get_status(result['candidateId'], include="applications,scores")
print(f"Candidate: {status['candidate']['firstName']} {status['candidate']['lastName']}")
# Move candidate to next step
move_result = client.programs.move_candidate(
program_id=program['id'],
candidate_id=result['candidateId'],
direction="next"
)
print(f"Moved from {move_result['movement']['from']['name']} to {move_result['movement']['to']['name']}")
Environment Variables
The SDK automatically reads from environment variables:
SEMANTIK_API_KEY(required): Your API keySEMANTIK_BASE_URL(optional): API base URL (defaults tohttps://gateway.semantikmatch.com)
Base URL Configuration
The SDK defaults to calling the production gateway service at https://gateway.semantikmatch.com. This is where all /api/v2/ endpoints are hosted.
For local development, override the base URL:
# Via constructor
client = Semantik(
api_key="sk_...",
base_url="http://localhost:9000" # Your local gateway service
)
# Or via environment variable
import os
os.environ["SEMANTIK_BASE_URL"] = "http://localhost:9000"
client = Semantik()
For different environments:
- Production:
https://gateway.semantikmatch.com(default) - Local:
http://localhost:9000 - Staging:
https://gateway-staging.semantikmatch.com(example)
API Reference
Programs
client.programs.list()- List all programsclient.programs.get(program_id)- Get a specific programclient.programs.list_candidates(program_id, ...)- List candidates in a programclient.programs.move_candidate(program_id, candidate_id, ...)- Move a candidate between steps
Candidates
client.candidates.submit_application(...)- Submit a new applicationclient.candidates.get_status(candidate_id, include=...)- Get candidate statusclient.candidates.get_applications(candidate_id, include=...)- Get all applicationsclient.candidates.get_scores(candidate_id, include=...)- Get candidate scoresclient.candidates.enroll(candidate_id, program_id, ...)- Enroll candidate in a program
Error Handling
The SDK raises ApiError for API-related errors:
from semantik import Semantik, ApiError
try:
program = client.programs.get(999)
except ApiError as e:
print(f"API Error {e.status}: {e}")
print(f"Path: {e.path}")
print(f"Response: {e.response}")
except Exception as e:
print(f"Unexpected error: {e}")
Type Hints
The SDK uses Python type hints for better IDE support. All methods are annotated with their return types.
Development
# Install in development mode
uv pip install -e .
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
python scripts/test_all_endpoints.py
# or
uv run python scripts/test_all_endpoints.py
# Format code
uv run black semantik/
# Type checking
uv run mypy semantik/
Documentation
For complete API documentation, see the JavaScript SDK Documentation which covers all endpoints. The Python SDK mirrors the same API structure.
Support
For issues, questions, or contributions, please refer to the main repository documentation or contact support.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semantik_sdk-0.1.0.tar.gz.
File metadata
- Download URL: semantik_sdk-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64971face1f37fa04ffb87be7de5b79eaa5b5c36d4cb14d954245d2b4bc652b9
|
|
| MD5 |
5781dc79363e33cfb51cfc5f31bad4b5
|
|
| BLAKE2b-256 |
0a00b3eeb7545af19bf819eb3e5c6ae9ea7e8a4e43dac1698176dc8ad9d07f86
|
File details
Details for the file semantik_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semantik_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18bd1396d63c35027beafd07c648a5ae843693be387838cae3187ed17a84f66a
|
|
| MD5 |
5efae3f707f00e15425f296fd106e4e6
|
|
| BLAKE2b-256 |
32133a398cf13923362894f4dada2c8f148500330a95a406d2dcdbc489e85f22
|