-
Notifications
You must be signed in to change notification settings - Fork 17
API Reference
Chintan Rathod edited this page Mar 26, 2025
·
1 revision
This document provides detailed information about the APIs used in Let's Stream V2.0.
interface SignUpParams {
email: string;
password: string;
}
interface SignUpResponse {
user: User;
token: string;
}interface SignInParams {
email: string;
password: string;
}
interface SignInResponse {
user: User;
token: string;
}interface SocialAuthParams {
provider: 'google';
}
interface SocialAuthResponse {
user: User;
token: string;
provider: string;
}interface MovieParams {
page?: number;
language?: string;
}
interface MovieResponse {
results: Movie[];
page: number;
total_pages: number;
total_results: number;
}interface SearchParams {
query: string;
page?: number;
include_adult?: boolean;
language?: string;
}interface TVParams {
page?: number;
language?: string;
}
interface TVResponse {
results: TVShow[];
page: number;
total_pages: number;
total_results: number;
}interface LiveMatchesParams {
sport?: string;
league?: string;
limit?: number;
}
interface LiveMatchesResponse {
matches: SportMatch[];
total: number;
}interface WatchHistoryEntry {
user_id: string;
media_id: string;
media_type: 'movie' | 'tv';
progress: number;
timestamp: number;
}interface GetHistoryParams {
user_id: string;
limit?: number;
offset?: number;
}
interface GetHistoryResponse {
history: WatchHistoryEntry[];
total: number;
}interface UserPreferences {
user_id: string;
theme?: string;
accentColor?: string;
isWatchHistoryEnabled: boolean;
notifications: {
enabled: boolean;
types: string[];
};
}interface UserPreferencesDoc {
user_id: string;
isWatchHistoryEnabled: boolean;
accentColor: string;
created_at: Timestamp;
updated_at: Timestamp;
}interface WatchHistoryDoc {
user_id: string;
media_id: string;
media_type: 'movie' | 'tv';
title: string;
poster_path: string;
watched_at: Timestamp;
progress: number;
}enum ErrorCode {
INVALID_CREDENTIALS = 'auth/invalid-credentials',
USER_NOT_FOUND = 'auth/user-not-found',
EMAIL_IN_USE = 'auth/email-already-in-use',
WEAK_PASSWORD = 'auth/weak-password',
NETWORK_ERROR = 'network/error',
API_ERROR = 'api/error',
RATE_LIMIT = 'api/rate-limit',
}interface ErrorResponse {
code: ErrorCode;
message: string;
details?: any;
}interface RateLimitConfig {
maxRequests: number;
timeWindow: number;
errorCode: ErrorCode;
}
const defaultConfig: RateLimitConfig = {
maxRequests: 100,
timeWindow: 60000,
errorCode: ErrorCode.RATE_LIMIT,
};interface UserEvent {
type: 'presence' | 'status' | 'preferences';
user_id: string;
data: any;
timestamp: number;
}interface MediaEvent {
type: 'play' | 'pause' | 'seek' | 'end';
media_id: string;
user_id: string;
timestamp: number;
data: {
progress?: number;
position?: number;
};
}interface ServiceWorkerEvent {
type: 'install' | 'activate' | 'update' | 'error';
timestamp: number;
details?: any;
}interface PushNotification {
title: string;
body: string;
icon?: string;
data?: {
url?: string;
action?: string;
[key: string]: any;
};
}interface AuthToken {
access_token: string;
refresh_token: string;
expires_in: number;
user_id: string;
}interface Session {
user: User;
tokens: AuthToken;
created_at: number;
expires_at: number;
}const auth = new Auth();
// Sign up
const user = await auth.signUp({
email: 'user@example.com',
password: 'password123'
});
// Sign in
const session = await auth.signIn({
email: 'user@example.com',
password: 'password123'
});
// Google sign in
const googleUser = await auth.socialAuth({
provider: 'google'
});const media = new MediaAPI();
// Get popular movies
const movies = await media.getPopular({
page: 1,
language: 'en'
});
// Search content
const results = await media.search({
query: 'matrix',
include_adult: false
});
// Get live sports
const matches = await media.getLiveMatches({
sport: 'football',
limit: 10
});const userAPI = new UserAPI();
// Update preferences
await userAPI.updatePreferences({
user_id: 'user123',
accentColor: '#ff0000',
isWatchHistoryEnabled: true
});
// Get watch history
const history = await userAPI.getHistory({
user_id: 'user123',
limit: 20
});Home • Getting Started • API Reference • Report Bug • Request Feature
© 2025 Let's Stream V2.0. Built with ❤️ by the community.