Chimoney / chimoney-community-projects

Repo for Community Contributors
http://api.chimoney.io/
MIT License
137 stars 173 forks source link

Integrate Chimoney with a Travel Booking Aggregator i.e TripAvisor, Booking.com #106

Open phyleria opened 1 year ago

phyleria commented 1 year ago

Example: Travelers looking to book flights and accommodations would want to compare prices in USD while making bookings in their local currency. They need a travel booking aggregator that offers this feature.

Idea Flow:

shivamkotalia14 commented 1 year ago

const express = require('express'); const axios = require('axios'); const app = express(); const PORT = process.env.PORT || 3000;

// Middleware for JSON parsing app.use(express.json());

// Example API Key for Chimoney (replace with your actual API key) const chimoneyApiKey = 'YOUR_CHIMONEY_API_KEY';

// Endpoint to get exchange rates from Chimoney app.get('/getExchangeRates', async (req, res) => { try { // Make a request to Chimoney's 'Get List of Exchange Rates' endpoint const response = await axios.get('https://api.chimoney.io/exchange-rates', { headers: { Authorization: Bearer ${chimoneyApiKey}, }, });

// Return the exchange rates to the frontend
res.json(response.data);

} catch (error) { console.error(error); res.status(500).json({ error: 'Error fetching exchange rates' }); } });

// Endpoint to convert local currency amount to USD app.post('/convertToUSD', async (req, res) => { try { const { localAmount, localCurrency } = req.body;

// Make a request to Chimoney's 'Convert Local Currency Amount to USD' endpoint
const response = await axios.post(
  'https://api.chimoney.io/convert-to-usd',
  { localAmount, localCurrency },
  {
    headers: {
      Authorization: `Bearer ${chimoneyApiKey}`,
    },
  }
);

// Return the converted amount to the frontend
res.json(response.data);

} catch (error) { console.error(error); res.status(500).json({ error: 'Error converting to USD' }); } });

app.listen(PORT, () => { console.log(Server is running on port ${PORT}); }); this code may solve this issue

Anurag-space commented 1 year ago

@phyleria I would like to contribute on this issue. could you please assign me this issue.