@bailaya/core
v1.3.1
Published
A TypeScript client for accessing the BailaYa public API
Readme
@bailaya/core
A TypeScript client for accessing the BailaYa public API
Overview
This package provides an easy-to-use wrapper around the BailaYa API, allowing developers to fetch studio profiles, instructors, classes, and more with TypeScript support and built-in parsing.
Features
- Type-safe API responses
- Automatic date parsing
- Optional studio ID configuration
- Graceful JSON fallback
- Supports querying by date and class type
Installation
npm install @bailaya/coreor with Yarn:
yarn add @bailaya/coreUsage
Basic Setup
import { BailayaClient } from '@bailaya/core';
const client = new BailayaClient({
studioId: 'your-studio-id', // Optional: can be set per call, or in environment variable `BAILAYA_STUDIO_ID`
});Get Studio Profile
const profile = await client.getStudioProfile();
console.log(profile.name);Get User Profile
const user = await client.getUserProfile('user-123');
console.log(user.bio.en);Get Instructors
const instructors = await client.getInstructors();
instructors.forEach(instr => console.log(instr.name));Get Upcoming Classes
const classes = await client.getClasses(new Date());Get Classes by Dance Type
const bachataClasses = await client.getClassesByType('bachata', new Date());API Reference
new BailayaClient(options)
Creates a new instance of the client.
Parameters:
options.baseUrl?: string— (Optional) Custom API base URL. Defaults to the official BailaYa API endpoint.options.studioId?: string— (Optional) Default studio ID used for methods that require it.
getStudioProfile(overrideId?: string): Promise<StudioProfile>
Fetches a single studio's profile, including metadata and supported dance types.
Parameters:
overrideId?: string— (Optional) Overrides the default studio ID.
Returns:
- A
Promisethat resolves to aStudioProfileobject with fields such asname,description,address,businessHours, and more.
getUserProfile(userId: string): Promise<UserProfile>
Fetches a specific user's profile, including their bio, image, and dance specialities.
Parameters:
userId: string— The unique ID of the user to retrieve.
Returns:
- A
Promisethat resolves to aUserProfileobject.
getInstructors(overrideId?: string): Promise<Instructor[]>
Retrieves all instructors linked to a studio.
Parameters:
overrideId?: string— (Optional) Overrides the default studio ID.
Returns:
- A
Promisethat resolves to an array ofInstructorobjects with parsedbiofields.
getClasses(from?: Date, overrideId?: string): Promise<StudioClass[]>
Fetches all upcoming classes in a 7-day window, starting from the given date.
Parameters:
from?: Date— (Optional) Starting date for the 7-day window. Defaults to today.overrideId?: string— (Optional) Overrides the default studio ID.
Returns:
- A
Promisethat resolves to an array ofStudioClassobjects. Dates are parsed asDateinstances.
getClassesByType(typeName: string, from?: Date, overrideId?: string): Promise<StudioClass[]>
Fetches upcoming classes for a specific dance type (e.g., "Salsa", "Bachata") within a 7-day window.
Parameters:
typeName: string— Name of the dance type to filter classes by.from?: Date— (Optional) Starting date for the 7-day window. Defaults to today.overrideId?: string— (Optional) Overrides the default studio ID.
Returns:
- A
Promisethat resolves to an array of filteredStudioClassobjects.
Types
All responses conform to typed interfaces like StudioProfile, Instructor, UserProfile, and StudioClass, defined in the types export.
License
ISC
