dermalytics
v0.2.0
Published
JavaScript/TypeScript SDK for the Dermalytics API - Skincare Ingredient Analysis
Maintainers
Readme
Dermalytics JavaScript/TypeScript SDK
JavaScript/TypeScript SDK for the Dermalytics API - Skincare Ingredient Analysis and Safety Ratings.
⚠️ Status
This SDK is currently in development and alpha testing. The API is functional but may have breaking changes in future versions. Use with caution in production environments.
Installation
npm install dermalyticsor with yarn:
yarn add dermalyticsor with pnpm:
pnpm add dermalyticsQuick Start
TypeScript/ES Modules
import { Dermalytics } from 'dermalytics';
// Initialize the client
const client = new Dermalytics({
apiKey: 'your_api_key_here'
});
// Get ingredient details
const ingredient = await client.getIngredient('niacinamide');
console.log(ingredient);
// Analyze a product
const analysis = await client.analyze([
'Aqua',
'Glycerin',
'Niacinamide',
'Salicylic Acid',
'Hyaluronic Acid'
]);
console.log(analysis);CommonJS
const { Dermalytics } = require('dermalytics');
const client = new Dermalytics({
apiKey: 'your_api_key_here'
});API Reference
new Dermalytics(config: DermalyticsConfig)
Initialize the Dermalytics API client.
Parameters:
config.apiKey(string): Your Dermalytics API keyconfig.baseUrl(string, optional): Base URL for the API (defaults tohttps://api.dermalytics.dev)
Throws:
ValidationError: If API key is missing or invalid
getIngredient(name: string): Promise<Ingredient>
Get detailed information about a specific ingredient.
Parameters:
name(string): The name of the ingredient to look up (e.g., "niacinamide")
Returns:
Promise<Ingredient>: Object containing:name(string): Ingredient nameseverity(string): Safety rating (e.g., "safe", "low_risk", "moderate_risk", "high_risk")description(string, optional): Description of the ingredientcategory(object): Category information withnameandslugcondition_safeties(array): Array of condition-specific safety informationsynonyms(array): Array of alternative names for the ingredient
Throws:
ValidationError: If the ingredient name is invalidNotFoundError: If the ingredient is not foundAuthenticationError: If authentication failsRateLimitError: If rate limit is exceededAPIError: For other API errors
analyze(ingredients: string[]): Promise<ProductAnalysis>
Analyze a complete product formulation.
Parameters:
ingredients(string[]): Array of ingredient names in the product
Returns:
Promise<ProductAnalysis>: Object containing:safety_status(string): Overall safety status of the productingredients(array): Array of analyzed ingredients with their safety ratingswarnings(array): Array of warnings for specific conditions or interactions
Throws:
ValidationError: If the ingredients array is invalidAuthenticationError: If authentication failsRateLimitError: If rate limit is exceededAPIError: For other API errors
Error Handling
The SDK provides comprehensive error handling with specific error classes for different scenarios:
import {
DermalyticsError,
APIError,
AuthenticationError,
NotFoundError,
RateLimitError,
ValidationError,
} from 'dermalytics';
try {
const ingredient = await client.getIngredient('niacinamide');
} catch (error) {
if (error instanceof NotFoundError) {
console.log('Ingredient not found');
} else if (error instanceof AuthenticationError) {
console.log('Invalid API key');
} else if (error instanceof RateLimitError) {
console.log('Rate limit exceeded');
} else if (error instanceof ValidationError) {
console.log('Invalid input:', error.message);
} else if (error instanceof APIError) {
console.log('API error:', error.message);
} else if (error instanceof DermalyticsError) {
console.log('Dermalytics error:', error.message);
}
}Error Classes
DermalyticsError- Base error class for all SDK errorsAPIError- General API errors (server errors, network issues, invalid responses)AuthenticationError- Authentication failures (401, 403)NotFoundError- Resource not found (404)RateLimitError- Rate limit exceeded (429)ValidationError- Invalid request data (400, invalid input parameters)
TypeScript Support
This SDK is written in TypeScript and includes full type definitions. All types are exported for your convenience:
import type {
Ingredient,
ProductAnalysis,
Category,
ConditionSafety,
IngredientAnalysis,
Warning,
DermalyticsConfig,
} from 'dermalytics';Development
Setup
- Clone the repository:
git clone https://github.com/dermalytics-dev/dermalytics-js.git
cd dermalytics-js- Install dependencies:
npm install- Build the project:
npm run buildRunning Tests
npm testLinting
npm run lintContributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License allows you to:
- ✅ Use the code commercially
- ✅ Modify the code
- ✅ Distribute the code
- ✅ Use privately
- ✅ Include in proprietary software
You must:
- Include the original copyright notice
- Include the license text
Links
Support
For support, email [email protected] or open an issue on GitHub.
