Skip to main content

Python SDK for the Dermalytics API - Skincare Ingredient Analysis

Project description

Dermalytics Python SDK

Python 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

pip install dermalytics

Quick Start

from dermalytics import Dermalytics

# Initialize the client
client = Dermalytics(api_key="your_api_key_here")

# Get ingredient details
ingredient = client.get_ingredient("niacinamide")
print(ingredient)
# {
#     "name": "niacinamide",
#     "severity": "safe",
#     "description": "A form of vitamin B3",
#     "category": {"name": "Vitamins", "slug": "vitamins"},
#     "condition_safeties": [],
#     "synonyms": ["nicotinamide"]
# }

# Analyze a product
analysis = client.analyze_product([
    "Aqua",
    "Glycerin",
    "Niacinamide",
    "Salicylic Acid",
    "Hyaluronic Acid"
])
print(analysis)
# {
#     "safety_status": "safe",
#     "ingredients": [...],
#     "warnings": []
# }

API Reference

Dermalytics(api_key: str, base_url: Optional[str] = None)

Initialize the Dermalytics API client.

Parameters:

  • api_key (str): Your Dermalytics API key
  • base_url (str, optional): Base URL for the API (defaults to https://api.dermalytics.dev)

Raises:

  • ValidationError: If API key is missing or invalid

get_ingredient(name: str) -> Ingredient

Get detailed information about a specific ingredient.

Parameters:

  • name (str): The name of the ingredient to look up (e.g., "niacinamide")

Returns:

  • Ingredient: Dictionary containing:
    • name (str): Ingredient name
    • severity (str): Safety rating (e.g., "safe", "low_risk", "moderate_risk", "high_risk")
    • description (str, optional): Description of the ingredient
    • category (dict): Category information with name and slug
    • condition_safeties (list): List of condition-specific safety information
    • synonyms (list): List of alternative names for the ingredient

Raises:

  • ValidationError: If the ingredient name is invalid
  • NotFoundError: If the ingredient is not found
  • AuthenticationError: If authentication fails
  • RateLimitError: If rate limit is exceeded
  • APIError: For other API errors

analyze_product(ingredients: List[str]) -> ProductAnalysis

Analyze a complete product formulation.

Parameters:

  • ingredients (List[str]): List of ingredient names in the product

Returns:

  • ProductAnalysis: Dictionary containing:
    • safety_status (str): Overall safety status of the product
    • ingredients (list): List of analyzed ingredients with their safety ratings
    • warnings (list): List of warnings for specific conditions or interactions

Raises:

  • ValidationError: If the ingredients array is invalid
  • AuthenticationError: If authentication fails
  • RateLimitError: If rate limit is exceeded
  • APIError: For other API errors

Error Handling

The SDK provides comprehensive error handling with specific error classes for different scenarios:

from dermalytics import (
    DermalyticsError,
    APIError,
    AuthenticationError,
    NotFoundError,
    RateLimitError,
    ValidationError,
)

try:
    ingredient = client.get_ingredient("niacinamide")
except NotFoundError:
    print("Ingredient not found")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except ValidationError as e:
    print(f"Invalid input: {e.message}")
except APIError as e:
    print(f"API error: {e.message}")
except DermalyticsError as e:
    print(f"Dermalytics error: {e.message}")

Error Classes

  • DermalyticsError - Base error class for all SDK errors
  • APIError - 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)

Development

Setup

  1. Clone the repository:
git clone https://github.com/dermalytics-dev/dermalytics-python.git
cd dermalytics-python
  1. Install development dependencies:
pip install -r requirements.txt
  1. Install the package in development mode:
pip install -e .

Running Tests

pytest

Code Formatting

black dermalytics tests

Type Checking

mypy dermalytics

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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 support@dermalytics.dev or open an issue on GitHub.

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

dermalytics-0.1.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

dermalytics-0.1.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file dermalytics-0.1.4.tar.gz.

File metadata

  • Download URL: dermalytics-0.1.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dermalytics-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e35ce381730bb207669a211d7e19904a4bc9a2bcb9c3646f711ef59d97a4f46b
MD5 b93afa9abb968c19f758a8698183246c
BLAKE2b-256 3bd7bdd02aab16c00db8db52002f60ad51e9e54bcc3e56c92f017618272529a0

See more details on using hashes here.

File details

Details for the file dermalytics-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: dermalytics-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dermalytics-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 31c5e843246a702b7406a602688900fc59a919e8b176ad5c835e9fd05c0be98a
MD5 bfce4579f337e6033a6fcc4dc5883e1e
BLAKE2b-256 5c9edd1cb269ffb106069284840b1405fd6951689f0304a5ad95cdde21035ad9

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