api-integration-wizards / api-config.js
kai774's picture
how i can give you API?
be85300 verified
// API Configuration for Hanzi Hunter
class APIConfig {
constructor() {
this.apis = {
// Free Chinese Dictionary API
dictionary: {
url: 'https://api.dictionaryapi.dev/api/v2/entries/zh/',
method: 'GET'
},
// HanziDB API for character information
hanzi: {
url: 'https://hanzi-db.herokuapp.com/api/characters/',
method: 'GET'
},
// Mock HSK API (you can replace with real API)
hsk: {
url: 'https://jsonplaceholder.typicode.com/posts',
method: 'GET'
},
// Backend API (replace with your actual backend URL)
backend: {
url: 'https://your-backend-api.com/api/',
method: 'POST'
}
};
}
// Method to set custom API endpoints
setAPI(name, url, method = 'GET') {
this.apis[name] = { url, method };
}
// Method to get API configuration
getAPI(name) {
return this.apis[name];
}
// Method to update all API configurations
updateAPIs(newConfigs) {
this.apis = { ...this.apis, ...newConfigs };
}
}
// Create global API config instance
window.apiConfig = new APIConfig();