fernandovaller/indices-economicos

自动获取最新发布的指数

v1.2 2024-09-10 21:00 UTC

This package is auto-updated.

Last update: 2024-09-10 21:02:02 UTC


README

作者: Fernando Valler
网站

本项目自动化获取最新发布的经济指数,例如

  • IGP-M (FGV)
  • INPC (IBGE)
  • IPCA (IBGE)
  • INCC-M (FGV)

🚀 简介

本项目简化了通过PHP直接访问主要经济指数的过程,允许在多种场景中使用,如仪表板、报告和财务分析。

要求

  • PHP 5.6+
  • Composer

📦 安装

  1. 克隆仓库

    git clone https://github.com/fernandovaller/indices-economicos.git
  2. 导航到项目目录

    cd indices-economicos
  3. 使用Composer安装依赖

    composer install

📚 使用示例

以下是一个使用本项目获取经济指数的基本示例

require __DIR__ . '/vendor/autoload.php';

use App\Sinduscon\Indice;

// Criar uma nova instância para buscar os índices
$indice = new Indice();

// Obter todos os índices mais recentes como array
$dados = $indice->build()->all();

// Obter todos os índices mais recentes como JSON
$dados = $indice->build()->json();

// Obter um índice específico (ex: IGP-M)
$dados = $indice->build()->get('IGP-M(FGV)');

// Listar todos os índices disponíveis
$listaIndices = $indice->listIndiceAllowed();

// Limpar cache e obter os índices novamente
$dados = $indice->clearCache()->build()->json();

📊 返回示例

API的返回结果将类似于以下示例

{
  "IGP-M(FGV)": {
    "indice": "IGP-M(FGV)",
    "url": "https://sindusconpr.com.br/?pid=309",
    "data": {
      "date": "2020-04-01",
      "value": "778,101",
      "variation_month": "0,80",
      "variation_year": "2,50",
      "variation_twelve_months": "6,68"
    }
  }
}

🛠️ 贡献

欢迎贡献!如果您发现问题或有改进建议,请随时提交issue或发送pull request。

📄 许可证

本项目采用MIT许可证