ymed-api
v1.0.0
Published
Official client for YMed Medical Conversation and Diagnosis APIs
Maintainers
Readme
ymed-api
Official JavaScript/TypeScript client for the YMed Medical Conversation and Diagnosis APIs. Use it to extract structured clinical data from doctor–patient conversations and to get AI-powered differential diagnoses.
- Medical Conversation: Send a transcript → get structured fields (chief complaints, medications, vitals, etc.).
- Diagnosis: Send symptoms and optional patient context → get primary and alternative diagnoses with likelihoods.
Get your API key at developers.ymed.ai.
Install
npm install ymed-apiRequires Node.js 18+ (uses native fetch).
Quick start
const { YMedClient } = require('ymed-api');
const client = new YMedClient({
apiKey: process.env.YMED_API_KEY,
// baseUrl: 'https://v1.api.ymed.ai', // optional, this is the default
});
// Extract structured data from a medical conversation
const extracted = await client.extractMedicalConversation({
conversation: 'Doctor: What brings you in? Patient: Fever and cough for 3 days. Doctor: Any medications? Patient: Lisinopril for blood pressure.',
});
console.log(extracted.data.chiefComplaints); // ['Fever', 'cough']
console.log(extracted.data.medications); // ['Lisinopril for blood pressure']
// Get a differential diagnosis
const diagnosis = await client.getDiagnosis({
symptoms: ['fever', 'cough'],
patientAge: 35,
patientSex: 'male',
});
console.log(diagnosis.data.primaryDiagnosis);
console.log(diagnosis.data.alternativeDiagnoses);TypeScript
Types are included. Example with explicit types:
import { YMedClient, type MedicalConversationData, type DiagnosisData } from 'ymed-api';
const client = new YMedClient({ apiKey: process.env.YMED_API_KEY! });
const res = await client.extractMedicalConversation({
conversation: 'Doctor: What brings you in? Patient: Headache and fever.',
});
const data: MedicalConversationData = res.data;API
new YMedClient(options)
| Option | Type | Required | Default | Description |
|-----------|--------|----------|--------------------------|--------------------------------|
| apiKey | string | Yes | — | API key from YMed Developers |
| baseUrl | string | No | https://v1.api.ymed.ai | API base URL |
| timeout | number | No | 60000 | Request timeout in milliseconds |
client.extractMedicalConversation(params)
- params.conversation (string, required): Full medical conversation transcript.
- Returns:
Promise<MedicalConversationResponse>withsuccess,data(chief complaints, medications, vitals, etc.), andmetadata.responseTime.
client.getDiagnosis(params)
- params.symptoms (string[], required): At least one symptom.
- params.patientAge (number, optional)
- params.patientSex (
'male' | 'female' | 'other', optional) - params.medicalHistory (string[], optional)
- params.currentMedications (string[], optional)
- params.vitalSigns (object with
temperature,bloodPressure,heartRate,respiratoryRate, optional) - Returns:
Promise<DiagnosisResponse>withsuccess,data.primaryDiagnosis,data.alternativeDiagnoses, andmetadata.responseTime.
Error handling
On HTTP errors (4xx/5xx), the client throws YMedApiError with:
message: Error message from the API or a generic one.statusCode: HTTP status (e.g. 401, 429, 500).body: Parsed error body when available (error,message,details).
const { YMedClient, YMedApiError } = require('ymed-api');
const client = new YMedClient({ apiKey: 'ymed_...' });
try {
const res = await client.extractMedicalConversation({ conversation: '...' });
console.log(res.data);
} catch (err) {
if (err instanceof YMedApiError) {
if (err.statusCode === 401) console.error('Invalid API key');
if (err.statusCode === 429) console.error('Rate limit exceeded');
console.error(err.message, err.body);
}
throw err;
}Rate limits
Rate limits are per API key and set in the Developers Portal. When exceeded, the API returns 429 and the client throws YMedApiError with statusCode: 429.
Links
License
MIT
