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 alpha. 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": "...",
# "comedogenicity": 0,
# "irritancy": 0,
# "formula": None,
# "category": "Vitamins", # or null
# "synonyms": ["nicotinamide"],
# "credits_remaining": 99,
# "trait_flags": [],
# # ... cas_no, ec_no, ph_eur_name, functions, etc.
# }
# Analyze a product
analysis = client.analyze_product([
"Aqua",
"Glycerin",
"Niacinamide",
"Salicylic Acid",
"Hyaluronic Acid"
])
print(analysis)
# {
# "safety_status": "safe",
# "ingredients": [
# {
# "name": "Aqua",
# "found": True,
# "severity": "safe",
# "category": "Solvent",
# # ...same detail fields as lookup
# }
# ],
# "credits_remaining": 99,
# }
API Reference
Dermalytics(api_key: str, base_url: Optional[str] = None)
Initialize the Dermalytics API client.
Parameters:
api_key(str): Your Dermalytics API keybase_url(str, optional): Base URL for the API (defaults tohttps://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: Matches OpenAPIIngredientResponse: detail fields above, includingtrait_flags, plusname,severity,category(string ornull),synonyms, andcredits_remaining.
Raises:
ValidationError: Invalid input or HTTP 400AuthenticationError: HTTP 401 / 403InsufficientCreditsError: HTTP 402NotFoundError: HTTP 404 (ingredient not found; no credit charged)RateLimitError: HTTP 429 (if returned by the service)APIError: Server or other errors (e.g. 500)
analyze_product(ingredients: List[str]) -> ProductAnalysis
Analyze a complete product formulation.
Parameters:
ingredients(List[str]): List of ingredient names in the product
Returns:
ProductAnalysis: Matches OpenAPIAnalyzeResponse:safety_status(Severity),ingredients(array ofIngredientAnalysis, includingtrait_flags), andcredits_remaining.
Raises:
ValidationError: Invalid body or HTTP 400 (no analyze charge on validation error per API docs)AuthenticationError: HTTP 401 / 403InsufficientCreditsError: HTTP 402RateLimitError: HTTP 429 (if returned by the service)APIError: Server or other errors (e.g. 500)
Error Handling
The SDK provides comprehensive error handling with specific error classes for different scenarios:
from dermalytics import (
DermalyticsError,
APIError,
AuthenticationError,
InsufficientCreditsError,
NotFoundError,
RateLimitError,
ValidationError,
)
try:
ingredient = client.get_ingredient("niacinamide")
except NotFoundError:
print("Ingredient not found")
except AuthenticationError:
print("Invalid API key")
except InsufficientCreditsError:
print("Not enough credits")
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 errorsAPIError- General API errors (server errors, network issues, invalid responses)AuthenticationError- Authentication failures (401, 403)InsufficientCreditsError- Insufficient credits (402)NotFoundError- Resource not found (404)RateLimitError- Rate limit exceeded (429)ValidationError- Invalid request data (400, invalid input parameters)
API error bodies follow ErrorResponse: nested error with at least code and message (and optional type). The client surfaces the message string on the exception.
Development
Setup
- Clone the repository:
git clone https://github.com/dermalytics-dev/dermalytics-python.git
cd dermalytics-python
- Install development dependencies:
pip install -r requirements.txt
- 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.
- 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 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
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 dermalytics-0.1.6.tar.gz.
File metadata
- Download URL: dermalytics-0.1.6.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d6e3fbabc9fdf34fdea2f6f888201208c5199e30d3e791ca27653438f47bf79
|
|
| MD5 |
c6737cf17f819c707df36cb92c38ea6d
|
|
| BLAKE2b-256 |
4a0a93bb2e5407c5be5fa8d3aa0e53eb5d25680404858bc5b5d5828aa0079352
|
File details
Details for the file dermalytics-0.1.6-py3-none-any.whl.
File metadata
- Download URL: dermalytics-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
728f1a1b8536e03a4274b51dd39baa6516f778bc2b05c0dae8f278af53252c9f
|
|
| MD5 |
27505f307f6cc98f45119e204b670bbf
|
|
| BLAKE2b-256 |
5e68e89136cfc7c005fb04eb3c646f78de6b1304578838bb74a3bc8b085fbe7d
|