This skill provides comprehensive backend REST API integration for Asleep sleep tracking platform. Use this skill when building server-side applications, API proxies for mobile apps, webhook event handlers, cross-platform backends (React Native, Flutter), analytics dashboards, or multi-tenant sleep tracking systems. Covers authentication, user management, session retrieval, statistics, webhook integration, and production-ready patterns with code examples in Python, Node.js, and curl.
View on GitHubasleep-ai/sleeptrack-skills
sleeptrack-skills
skills/sleeptrack-be/SKILL.md
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/asleep-ai/sleeptrack-skills/blob/main/skills/sleeptrack-be/SKILL.md -a claude-code --skill sleeptrack-beInstallation paths:
.claude/skills/sleeptrack-be/# Sleeptrack Backend API Integration
## Overview
This skill provides comprehensive guidance for integrating the Asleep REST API into backend applications. It covers server-side user management, session data retrieval, statistics aggregation, webhook event handling, and production-ready patterns for building robust sleep tracking backends.
**Use this skill when:**
- Building backend/server-side sleep tracking integrations
- Creating API proxies for mobile applications
- Implementing webhook handlers for real-time sleep data
- Developing cross-platform backends (React Native, Flutter)
- Building analytics dashboards and reporting systems
- Creating multi-tenant sleep tracking applications
- Integrating sleep data with other health platforms
## Quick Start
### 1. Get Your API Key
1. Sign up at https://dashboard.asleep.ai
2. Generate an API key for your application
3. Store securely in environment variables (never commit to version control)
### 2. Basic Authentication
All API requests require the `x-api-key` header:
**curl:**
```bash
curl -X GET "https://api.asleep.ai/ai/v1/users/USER_ID" \
-H "x-api-key: YOUR_API_KEY"
```
**Python:**
```python
import requests
headers = {"x-api-key": "YOUR_API_KEY"}
response = requests.get(
"https://api.asleep.ai/ai/v1/users/USER_ID",
headers=headers
)
```
**Node.js:**
```javascript
const axios = require('axios');
const response = await axios.get(
'https://api.asleep.ai/ai/v1/users/USER_ID',
{
headers: { 'x-api-key': 'YOUR_API_KEY' }
}
);
```
## API Client Structure
Build a reusable API client to handle authentication, error handling, and common operations.
**Key Components:**
- Base URL configuration (`https://api.asleep.ai`)
- API key authentication in headers
- Error handling for common HTTP status codes (401, 403, 404)
- Request methods for all API endpoints
- Session management with persistent connections
**For complete implementations:**
- Python: See `references/python_client_implementation.md