Discover our comprehensive guide on integrating Bolt.new AI with Zocdoc. Follow easy steps to streamline patient bookings and boost efficiency.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
zocdoc.ts
within a folder called integrations
in your project’s source directory. The path should be src/integrations/zocdoc.ts
.
// src/integrations/zocdoc.ts
// This class encapsulates methods to interact with the Zocdoc API
export class ZocdocClient {
private apiKey: string;
private baseUrl: string;
constructor(apiKey: string) {
// Initialize with your Zocdoc API key
this.apiKey = apiKey;
// Set the base URL for Zocdoc API endpoints (update if necessary)
this.baseUrl = 'https://api.zocdoc.com';
}
// Example method: Fetch doctor's availability
async getDoctorAvailability(doctorId: string): Promise {
const endpoint = ${this.baseUrl}/doctors/${doctorId}/availability;
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': Bearer ${this.apiKey}
}
});
if (!response.ok) {
throw new Error('Error fetching doctor availability');
}
return response.json();
}
// Add more methods for other Zocdoc API calls as needed
}
index.ts
or main.ts
) where you want to utilize the Zocdoc integration.ZocdocClient
from the integration file you just created.YOURZOCDOCAPI_KEY
with your actual key.)
// Example code in your main file (e.g., src/main.ts)
import { ZocdocClient } from './integrations/zocdoc';
// Replace with your actual Zocdoc API key
const zocdocApiKey: string = 'YOURZOCDOCAPI_KEY';
// Initialize the Zocdoc client
const zocdocClient = new ZocdocClient(zocdocApiKey);
// Example usage: Retrieve the availability for a given doctor
const doctorId = '12345';
zocdocClient.getDoctorAvailability(doctorId)
.then(availability => {
console.log('Doctor availability:', availability);
})
.catch(error => {
console.error('Error fetching availability:', error);
});
fetch
API for HTTP requests. Ensure that your project environment supports fetch
(most modern browsers and some runtimes provide this natively).fetch
), add the following snippet at the very top of your main file to import the polyfill:
// Add this at the top of your main file if running in Node.js and fetch is not available
import 'node-fetch'; // This will import the fetch polyfill
config.ts
or similar), add your Zocdoc API key there. For example:
// src/config.ts
export const API_KEYS = {
ZOCDOC: 'YOURZOCDOCAPI_KEY'
// Add any other API keys or secrets needed
};
// src/main.ts
import { API_KEYS } from './config';
import { ZocdocClient } from './integrations/zocdoc';
const zocdocClient = new ZocdocClient(API_KEYS.ZOCDOC);
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.