定制 commodities-api/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

commodities-api/sdk

Composer 安装命令:

composer require commodities-api/sdk

包简介

Official PHP client for the Commodities-API.

README 文档

README

Official PHP client for the Commodities-API.

Installation

composer require commodities-api/sdk

Usage

<?php

require 'vendor/autoload.php';

use CommoditiesApi\CommoditiesClient;

$client = new CommoditiesClient('YOUR_ACCESS_KEY');

$response = $client->getLatest([
    'base'    => 'USD',
    'symbols' => 'RICE,WHEAT,SUGAR',
]);

print_r($response);

Methods

// Latest rates
$client->getLatest([
  'base'    => 'USD',
  'symbols' => 'RICE,WHEAT,SUGAR',
]);

// Historical (YYYY-MM-DD)
$client->getHistorical('2024-05-15', [
  'base'    => 'USD',
  'symbols' => 'WTIOIL,GOLD',
]);

// Time-series
$client->getTimeSeries([
  'start_date' => '2024-01-01',
  'end_date'   => '2024-01-31',
  'base'       => 'USD',
  'symbols'    => 'WTIOIL',
]);

// Fluctuation
$client->getFluctuation([
  'start_date' => '2024-01-01',
  'end_date'   => '2024-01-31',
  'base'       => 'USD',
  'symbols'    => 'WTIOIL,GOLD',
]);

// Convert
$client->convert([
  'from'   => 'USD',
  'to'     => 'WTIOIL',
  'amount' => 100,
]);

// Symbols
$client->getSymbols();

// Seasonality (cuando exista el endpoint)
$client->getSeasonality([
  'symbol'   => 'WTIOIL',
  'group_by' => 'month',
  'years'    => 5,
]);

Error handling

use CommoditiesApi\CommoditiesApiException;

try {
    $response = $client->getLatest(['base' => 'USD']);
} catch (CommoditiesApiException $e) {
    echo $e->getMessage();
    echo $e->getStatusCode();
    var_dump($e->getRaw());
}

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固