A TypeScript client library for the Hallocasa API, generated from the OpenAPI specification.
- 🚀 Type-safe API client for Hallocasa services
- 📚 Complete TypeScript type definitions
- 🔍 Automatically generated from OpenAPI specification
- 🔄 Axios-based HTTP client with configurable options
- 💡 Easy to use, with a simple and intuitive API
# Clone this repository and navigate to the client directory
cd hallocasa-api-client
# Install dependencies
npm install
# Generate the API client from the OpenAPI spec
npm run generate
# Build the TypeScript code
npm run buildOr simply run the build script:
./build.shAfter building, you can use the library in your TypeScript or JavaScript project:
import { createHallocasaClient } from 'hallocasa-api-client';
// Create a configured client instance
const client = createHallocasaClient({
baseURL: 'https://api.hallocasa.com',
// Optional: Include an API key if required
// apiKey: 'your-api-key',
// Optional: Include auth token if available
// token: 'your-auth-token',
});
// Example: Get all countries
async function getAllCountries() {
try {
const response = await client.countriesApi.getAllCountries();
console.log(response.data);
} catch (error) {
console.error('Error fetching countries:', error);
}
}
// Example: Get user favorites
async function getUserFavorites(userId: number) {
try {
const response = await client.favoritesApi.getByUser_1(userId);
console.log(response.data);
} catch (error) {
console.error('Error fetching user favorites:', error);
}
}The Hallocasa API client supports two authentication methods:
- API Key Authentication: Pass your API key in the
apiKeyoption when creating a client. - Bearer Token Authentication: Pass your authentication token in the
tokenoption when creating a client.
// With API key authentication
const client = createHallocasaClient({
baseURL: 'https://api.hallocasa.com',
apiKey: 'your-api-key',
});
// With Bearer token authentication
const client = createHallocasaClient({
baseURL: 'https://api.hallocasa.com',
token: 'your-auth-token',
});hallocasa-api-client/
├── src/ # Source code
│ ├── generated/ # Generated API code (created after running generate)
│ ├── client.ts # Client configuration
│ └── index.ts # Main entry point
├── scripts/ # Build and utility scripts
├── examples/ # Usage examples
├── dist/ # Build output (created after running build)
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
npm run generate: Generate API client from OpenAPI specnpm run update-client: Update client.ts with generated API clientsnpm run build: Build the TypeScript codenpm run clean: Remove build output