Skip to content

Postgres extension client for OpenExchangeRates API

License

Notifications You must be signed in to change notification settings

brunoenten/pg_oxr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenExchangeRates API Client for PostgreSQL

pg_oxr is a PostgreSQL extension that integrates with the OpenExchangeRates API, enabling you to fetch and manage currency exchange rates directly within your database. This extension simplifies workflows requiring real-time exchange rate data in PostgreSQL.

Features

  • Fetch Exchange Rates: Seamlessly retrieve live exchange rates from OpenExchangeRates.
  • Configuration Management: Manage API keys and settings using PostgreSQL functions.
  • Integrated Workflow: Combine exchange rate data with existing database operations for analytics or reporting.

Prerequisites

Before installing pg_oxr, ensure you have the following:

  • PostgreSQL 13 or higher.
  • Access to the OpenExchangeRates API (requires an API key).
  • Build tools such as make and gcc.

Installation

  1. Clone the Repository:

    git clone https://github.com/yourusername/pg_oxr.git
    cd pg_oxr
  2. Build and Install the Extension:

    make
    sudo make install
  3. Enable the Extension in Your Database:

    CREATE EXTENSION oxr;

Configuration

To configure the extension, set the API key for OpenExchangeRates in your database using the configuration function:

-- Store your API key (replace 'your_api_key' with your actual key)
SELECT oxr.set_config('api_key', 'your_api_key');

Usage

Once configured, use the provided functions to interact with the API. For example:

  1. Get the Current Exchange Rate:

    SELECT oxr.get_exchange_rate('USD', 'EUR');
  2. Fetch and Store Rates: Automate fetching exchange rates periodically to store them in a local table for quick access.

  3. Custom Integrations: Combine oxr functions with other SQL queries for analytics, billing, or reporting workflows.

Contributing

We welcome contributions to enhance the functionality of pg_oxr. To contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with detailed explanations of changes.

License

This project is licensed under the MIT License. See the LICENSE.txt file for details.

Acknowledgments

Special thanks to the PostgreSQL and OpenExchangeRates teams for their excellent tools and services that made this extension possible.

About

Postgres extension client for OpenExchangeRates API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published