tau-sdk
v1.0.0
Published
Official JavaScript/TypeScript SDK for TAU Service Marketplace API
Maintainers
Readme
TAU JavaScript SDK
The official JavaScript/TypeScript client for the TAU Service Marketplace API.
Installation
npm install tau-sdk
# or
yarn add tau-sdkGetting Started
Initialize the client with your API key. You can get an API key from the Developer Portal.
import { TauClient } from 'tau-sdk';
const client = new TauClient({
apiKey: 'tau_live_xxxxxxxxxxxxxxxxxxxxxxxx',
// Optional: Override base URL for testing or enterprise instances
// baseUrl: 'https://api.tau.app/api/v1'
});Usage
Services
List available services, search by category, or find nearest providers.
// List all services
const { data: services } = await client.services.list();
// Search services
const { data: results } = await client.services.list({
search: 'Plumbing',
categoryId: 'cat_123'
});
// Get service details
const { data: service } = await client.services.get('service_123');Providers
Find and view service providers.
// Find providers near a location
const { data: providers } = await client.providers.list({
latitude: 37.7749,
longitude: -122.4194,
radius: 5000 // 5km radius
});
// Get provider schedule/availability
const { data: slots } = await client.providers.availability('provider_123');Bookings
Manage bookings (create, list, cancel).
// Create a new booking
const { data: booking } = await client.bookings.create({
serviceId: 'service_123',
providerId: 'provider_123',
scheduledAt: '2024-03-20T10:00:00Z',
notes: 'Gate code is 1234'
});
// List my bookings (Consumer)
const { data: myBookings } = await client.bookings.list({ status: 'CONFIRMED' });
// Cancel a booking
await client.bookings.cancel('booking_123', 'Changed my mind');Authentication
If building a client-side app (like a mobile app), you can handle user auth directly.
// Login
const { data: session } = await client.auth.login('[email protected]', 'password123');
console.log(session.accessToken);
// Register
await client.auth.register({
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
password: 'securePassword123'
});Error Handling
The SDK throws TauApiError for API errors.
import { TauClient, TauApiError } from 'tau-sdk';
try {
await client.bookings.create({ ... });
} catch (error) {
if (error instanceof TauApiError) {
console.error('API Error:', error.code, error.message);
if (error.details) {
console.error('Validation errors:', error.details);
}
} else {
console.error('Unknown error:', error);
}
}License
MIT
