SDKs overview

Fixer provides a range of Software Development Kits (SDKs) and community-contributed libraries designed to simplify the integration of its currency exchange rate API. These SDKs abstract the underlying RESTful API calls, handling common tasks such as HTTP requests, response parsing (often JSON), and authentication. By using an SDK, developers can reduce the boilerplate code required to interact with the Fixer API, leading to faster development and easier maintenance.

The core functionality accessible via these SDKs includes fetching real-time exchange rates for over 170 world currencies, retrieving historical rates for specific dates, converting amounts between currencies, and accessing time-series data. Each SDK is tailored to its respective programming language, adhering to common idioms and best practices for that ecosystem. This allows developers to integrate Fixer's services using familiar patterns.

For instance, a Python SDK might map API endpoints to method calls on an object, returning native Python data structures. Similarly, a Node.js library would offer asynchronous functions that resolve with JavaScript objects. This approach contrasts with making raw HTTP requests, which requires manual construction of URLs, headers, and request bodies, along with subsequent parsing of the JSON response. The official Fixer documentation provides detailed examples across several popular programming languages, illustrating these integration patterns for various API endpoints like /latest, /convert, and /historical API usage examples.

Official SDKs by language

Fixer offers official support and examples for several popular programming languages, focusing on direct API integration rather than formal, standalone SDK packages. These examples often serve as a strong foundation for developers to build their own wrapper functions or integrate directly. The primary languages showcased in the official Fixer documentation reflect common development environments.

The following table summarizes the key official integration methods and examples provided by Fixer:

Language Integration Method / Example Type Typical Installation / Usage Maturity / Support
PHP cURL-based examples, custom client library patterns composer require guzzlehttp/guzzle (for HTTP client) or native cURL Well-documented, actively maintained examples
Python requests library examples, custom client library patterns pip install requests Well-documented, actively maintained examples
Node.js fetch API or axios examples npm install axios or native fetch (Node.js 18+) Well-documented, actively maintained examples
jQuery AJAX examples Included via CDN or local download in web projects Legacy web context, examples provided
Go Standard library net/http examples Native Go modules Examples available
Ruby Net::HTTP or httparty examples gem install httparty or native Ruby standard library Examples available
cURL Command-line examples Pre-installed on most Unix-like systems Universal, foundational examples

These examples illustrate how to construct API requests, include the API key for authentication, and parse the JSON responses using standard libraries or widely adopted third-party HTTP clients within each language's ecosystem. For a complete list of these examples, refer to the official Fixer documentation.

Installation

Installing the necessary components to interact with the Fixer API typically involves adding an HTTP client library to your project, as Fixer primarily provides code examples rather than standalone SDK packages for many languages. The specific installation steps depend on your chosen programming language and package manager.

PHP Installation

For PHP, you can use Composer to install an HTTP client like Guzzle, which is a popular choice for making HTTP requests:

composer require guzzlehttp/guzzle

Alternatively, you can use PHP's native cURL extension, which is often enabled by default in server environments. No additional installation is required for cURL if it's already available.

Python Installation

Python developers commonly use the requests library. Install it using pip:

pip install requests

This library simplifies HTTP requests and response handling in Python, making it a suitable choice for integrating with Fixer.

Node.js Installation

In Node.js projects, axios is a widely used promise-based HTTP client. Install it via npm:

npm install axios

For newer Node.js versions (18+), the native fetch API is also available globally, requiring no extra installation. For older versions or browser environments, polyfills or specific libraries might be needed to use fetch.

Go Installation

Go applications typically rely on the standard library's net/http package for making HTTP requests. No external package installation is usually required for basic API interaction, as the necessary components are built into the Go runtime:

import (
    "net/http"
    "io/ioutil"
)

// ... code to use http.Get or http.Post ...

Ruby Installation

Ruby developers can use the standard library's Net::HTTP module. For a more user-friendly interface, the httparty gem is a common choice:

gem install httparty

Include it in your Ruby script with require 'httparty'.

cURL Installation

cURL is a command-line tool and library for transferring data with URLs. It is typically pre-installed on macOS, Linux, and Windows 10/11. No separate installation step is usually required to use cURL from the command line.

Quickstart example

This quickstart example demonstrates how to retrieve the latest exchange rates using Python and the requests library. This approach is common across many languages, adapting the HTTP client and JSON parsing methods.

Prerequisites:

  • A Fixer API Access Key (available upon Fixer account signup).
  • Python installed on your system.
  • The requests library installed (pip install requests).

Python Code Example:

import requests

ACCESS_KEY = 'YOUR_ACCESS_KEY'  # Replace with your actual Fixer API Access Key
BASE_CURRENCY = 'USD'           # Optional: Specify a base currency (requires a paid plan for non-EUR bases)

def get_latest_rates(access_key, base=None):
    url = f"http://data.fixer.io/api/latest?access_key={access_key}"
    if base:
        url += f"&base={base}"
        
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)
        data = response.json()
        
        if data.get('success'):
            print(f"Date: {data['date']}")
            print(f"Base Currency: {data['base']}")
            print("Rates:")
            for currency, rate in data['rates'].items():
                print(f"  {currency}: {rate}")
        else:
            print(f"API Error: {data.get('error', {}).get('info', 'Unknown error')}")

    except requests.exceptions.HTTPError as errh:
        print(f"Http Error: {errh}")
    except requests.exceptions.ConnectionError as errc:
        print(f"Error Connecting: {errc}")
    except requests.exceptions.Timeout as errt:
        print(f"Timeout Error: {errt}")
    except requests.exceptions.RequestException as err:
        print(f"Something Else: {err}")

# Call the function to get the latest rates
get_latest_rates(ACCESS_KEY, BASE_CURRENCY)

This script constructs the API URL with your access key, makes a GET request, checks for HTTP errors, and then parses the JSON response to print the latest exchange rates. Remember that the free tier limits the base currency to EUR; specifying a different base currency requires a paid Fixer subscription, as detailed on the Fixer pricing page.

Community libraries

While Fixer provides robust official examples and direct API integration guidelines, the open-source community has developed various wrapper libraries and SDKs for different programming languages. These community-contributed projects often aim to provide a more idiomatic interface to the Fixer API for specific language ecosystems, sometimes including features like object-oriented models for currency data, improved error handling, or asynchronous capabilities.

Developers often search for these libraries on package managers like npm for Node.js, PyPI for Python, or Packagist for PHP. For example, a search on PyPI for "Fixer API" might yield several Python packages that abstract Fixer's endpoints. These libraries are typically maintained by individual developers or small teams and may vary in their level of active support, feature completeness, and adherence to the latest Fixer API changes.

Before adopting a community library, it is advisable to evaluate its:

  • Maintenance Status: Check the last commit date, open issues, and pull requests on its GitHub repository (if available).
  • Documentation: Assess the clarity and completeness of its usage instructions and examples.
  • Community Activity: Look for signs of an active community, such as forum discussions or recent contributions.
  • Compatibility: Ensure it supports the version of the Fixer API you intend to use and your project's language version.
  • Licensing: Verify the license is compatible with your project's requirements, typically an open-source license like MIT or Apache 2.0, as discussed in general open-source software licensing principles.

For instance, a developer looking for a Node.js wrapper might explore options on npmjs.com that provide a more JavaScript-friendly promise-based interface to the Fixer API. These libraries could offer helper methods for common tasks like fixer.latest('USD', ['GBP', 'JPY']), simplifying the interaction beyond raw HTTP calls. While not officially endorsed, these tools can provide significant convenience for developers.

It is important to note that community libraries are not officially supported by Fixer. For critical applications, developers might prefer to use the official examples as a base or build their own thin wrapper, ensuring full control over the API interaction and error handling. For developers seeking to understand broader API client library design patterns, resources like Google's API Client Library Guidelines can provide valuable insights into what makes a robust and user-friendly SDK.