Download the PHP package wprigollopes/bcb-ptax without Composer

On this page you can find all versions of the php package wprigollopes/bcb-ptax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bcb-ptax

BCB PTAX

A PHP library to fetch daily PTAX exchange rates from Banco Central do Brasil's public API.

Background

This project was born out of a real operational need at a Brazilian import company. Every business day, the company needed the official PTAX closing rate to price imports, settle invoices, and comply with Brazilian customs regulations. What started as a quick utility script grew into a Composer package shared with the community.

In 2026, the library was modernized with the help of Claude Code — rewritten from the ground up with PHP 8.1+ features, proper type safety, full test coverage, and i18n support while keeping the same simple API.

Requirements

Installation

Usage

Basic example

Custom HTTP client

If you need to configure timeouts, proxies, or other HTTP options, pass your own Guzzle client:

Portuguese error messages

Exception messages default to English (en_US). To get messages in Portuguese:

Handling errors

Working with user input

The Currency enum provides safe parsing from strings:

Supported Currencies

The BCB PTAX service provides daily closing rates for the following currencies against BRL:

Code Currency
AUD Australian Dollar
CAD Canadian Dollar
CHF Swiss Franc
DKK Danish Krone
EUR Euro
GBP British Pound
JPY Japanese Yen
NOK Norwegian Krone
SEK Swedish Krona
USD US Dollar

Source: BCB PTAX Moedas endpoint

API Reference

PTAX

get(Currency $currency, DateTimeInterface $date): PTAXResult

Fetches the closing PTAX rate for the given currency and date. Throws ApiException if the API returns an error, the response is malformed, or no closing PTAX exists for that date (weekends, holidays).

PTAXResult

Property Type Description
buyRate float Purchase rate (cotacaoCompra)
sellRate float Selling rate (cotacaoVenda)
date DateTimeImmutable Quotation timestamp
bulletinType string Bulletin type (always "Fechamento PTAX")

Currency

PHP 8.1 string-backed enum with all 10 supported currency codes. Use Currency::tryFrom('USD') for safe parsing from user input.

Development

License

MIT


All versions of bcb-ptax with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wprigollopes/bcb-ptax contains the following files

Loading the files please wait ...