SDKs overview
Infermedica provides software development kits (SDKs) to facilitate the integration of its AI-powered diagnostic and symptom assessment capabilities into various digital health applications. These SDKs are designed to abstract the complexities of direct API interaction, allowing developers to incorporate features like symptom checking, triage recommendations, and access to medical knowledge bases more efficiently. The primary focus for Infermedica's official SDKs has been the JavaScript ecosystem, catering to web-based and potentially hybrid mobile application development.
The Infermedica API platform offers services that enable applications to query for potential diagnoses based on reported symptoms, assess risk, and guide users through a structured interview process. The SDKs wrap these API functionalities, providing a more idiomatic way for developers to interact with the underlying services. This approach aims to reduce development time and effort for partners building solutions in areas such as digital health platforms, call center support, and patient engagement tools, as detailed in the Infermedica developer documentation.
While the core offering centers on JavaScript, developers can technically interact with Infermedica's RESTful API directly using any language capable of making HTTP requests. However, using the official SDK often provides benefits such as simplified authentication, type safety (in languages that support it), and higher-level abstractions for common use cases. This can be particularly useful when dealing with the nuanced medical reasoning and data structures that Infermedica's API provides.
Official SDKs by language
Infermedica officially supports a JavaScript SDK, which serves as the primary method for integrating their API services into web applications and other JavaScript-dependent environments. This SDK is maintained by Infermedica to ensure compatibility with their latest API versions and to provide a consistent development experience.
The SDK typically handles aspects such as API request formatting, response parsing, and error handling, allowing developers to focus on the user interface and application logic. It is structured to interact with the various endpoints of the Infermedica API, including those for starting a new diagnostic session, submitting symptoms, retrieving differential diagnoses, and accessing medical concept information. Developers should refer to the Infermedica API Reference for details on available endpoints and data models.
Official SDKs
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| JavaScript | @infermedica/sdk |
npm install @infermedica/sdk |
Stable, Actively Maintained |
Installation
The official Infermedica JavaScript SDK is distributed via npm, the Node.js package manager. This makes it installable in most JavaScript projects, whether they are front-end web applications (using bundlers like Webpack or Vite) or Node.js backend services. Before installation, ensure you have Node.js and npm installed on your development machine. Instructions for installing Node.js can be found on the official Node.js website.
To install the Infermedica SDK in your project, navigate to your project directory in your terminal and execute the following command:
npm install @infermedica/sdk
This command will download the SDK package and its dependencies, adding them to your project's node_modules directory and updating your package.json file. Once installed, you can import and use the SDK in your JavaScript or TypeScript files.
For projects using Yarn, an alternative package manager, the installation command would be:
yarn add @infermedica/sdk
After installation, the SDK can be imported using standard ES module syntax (import) or CommonJS syntax (require), depending on your project's configuration and target environment.
Quickstart example
This quickstart example demonstrates how to initialize the Infermedica SDK and perform a basic symptom assessment. To use the SDK, you will need an App ID and App Key, which are provided upon obtaining API access from Infermedica. These credentials are essential for authenticating your requests against the Infermedica API. For security best practices, especially in client-side applications, consider using a proxy server to keep your API keys secure and prevent exposure in public repositories, a common practice in API integration as described in Google's API key best practices.
The example below outlines a simple interaction: starting a new diagnostic session, adding an initial symptom, and retrieving the next set of questions or a preliminary diagnosis.
import { InfermedicaApi, Sex, Age } from '@infermedica/sdk';
// Replace with your actual App ID and App Key from Infermedica
const APP_ID = 'YOUR_APP_ID';
const APP_KEY = 'YOUR_APP_KEY';
const infermedicaApi = new InfermedicaApi(APP_ID, APP_KEY);
async function runDiagnosis() {
try {
// 1. Initialize a new diagnosis session
const initialDiagnosis = await infermedicaApi.diagnosis({
sex: Sex.MALE,
age: Age.years(30)
});
console.log('Initial Diagnosis:', initialDiagnosis);
// 2. Add an initial symptom (e.g., headache)
// You would typically get symptom IDs from Infermedica's /search or /symptoms endpoint
const headacheSymptomID = 's_101'; // Example symptom ID for headache
const updatedDiagnosis = await infermedicaApi.diagnosis({
sex: Sex.MALE,
age: Age.years(30),
// The 'evidence' array contains observed symptoms and their states
evidence: [
{ id: headacheSymptomID, choice_id: 'present' } // 'present', 'absent', 'unknown'
]
});
console.log('Diagnosis after adding headache:', updatedDiagnosis);
// 3. Process the diagnosis response
// The response contains 'question' for next steps or 'conditions' for potential diagnoses
if (updatedDiagnosis.question) {
console.log('Next question:', updatedDiagnosis.question.text);
// In a real application, you would present this question to the user
// and then call infermedicaApi.diagnosis again with the user's answer.
} else if (updatedDiagnosis.conditions) {
console.log('Potential conditions:');
updatedDiagnosis.conditions.forEach(condition => {
console.log(`- ${condition.name} (probability: ${condition.probability.toFixed(2)})`);
});
}
} catch (error) {
console.error('Error during diagnosis:', error.message);
if (error.response) {
console.error('API Error Response:', error.response.data);
}
}
}
runDiagnosis();
This example demonstrates the basic flow: setting up the client, initiating a diagnosis, providing initial evidence (symptoms), and then processing Infermedica's response, which might include further questions or a list of potential conditions. For a complete understanding of all available parameters and methods, refer to the Infermedica API documentation.
Community libraries
As of the current information, Infermedica's developer ecosystem is primarily supported by its official JavaScript SDK. There is limited public information available regarding widely adopted or officially recognized community-contributed libraries or SDKs for other programming languages. This often indicates a strategic focus on direct API integration for enterprise partners or a preference for the officially provided SDK for general development.
Developers working in languages other than JavaScript may need to interact with the Infermedica API directly. The API is a RESTful service, meaning it communicates over standard HTTP methods (GET, POST) and typically uses JSON for request and response bodies. This design allows for integration from virtually any programming language that can make web requests, such as Python, Java, C#, Go, or Ruby.
When interacting directly with a REST API, developers typically handle the following:
- HTTP Client: Using a library specific to their language (e.g.,
requestsin Python,OkHttpin Java,HttpClientin C#) to send HTTP requests. - Authentication: Including the necessary
App-IdandApp-Keyheaders in each request as required by Infermedica's authentication scheme. - Request Body Construction: Serializing data structures (like symptom evidence, patient demographics) into JSON format for POST requests.
- Response Parsing: Deserializing JSON responses from the API into native data structures for further processing within the application.
- Error Handling: Implementing logic to manage various HTTP status codes and API-specific error messages.
While community libraries can emerge based on developer demand, their stability, maintenance, and feature parity with the official API can vary. Developers are advised to consult the Infermedica developer portal for any updates on officially supported SDKs or recommended community projects.