cryptocontrol/crypto-news-api

客户端从CryptoControl API获取应用中的加密货币新闻源

2.3.0 2018-08-23 16:24 UTC

This package is not auto-updated.

Last update: 2024-09-22 16:23:44 UTC


README

官方PHP客户端,用于CryptoControl.io API。CryptoControl PHP客户端让开发者能够访问来自世界各地的加密新闻源中的丰富格式化文章。

安装

composer require cryptocontrol/crypto-news-api

使用

首先确保您已经通过访问https://cryptocontrol.io/apis获取了API密钥。有了API密钥,您可以编写以下代码。

$api = new CryptoControl\CryptoNewsApi("API_KEY_HERE");

# Enable the sentiment datapoints
$api->enableSentiment();

# get top news
print_r($api->getTopNews());

# get latest russian news
print_r($api->getLatestNews("ru"));

# get top bitcoin news
print_r($api->getTopNewsByCoin("bitcoin"));

# get top EOS tweets
print_r($api->getTopTweetsByCoin("eos"));

# get top Ripple reddit posts
print_r($api->getLatestRedditPostsByCoin("ripple"));

# get reddit/tweets/articles in a single combined feed for NEO
print_r($api->getTopFeedByCoin("neo"));

# get latest reddit/tweets/articles (seperated) for Litecoin
print_r($api->getLatestItemsByCoin("litecoin"));

# get details (subreddits, twitter handles, description, links) for ethereum
print_r($api->getCoinDetails("ethereum"));

可用函数

  • getTopNews(lang?: enum) 获取顶级新闻文章。
  • getLatestNews(lang?: enum) 获取最新新闻文章。
  • getTopNewsByCategory(lang?: enum) 按类别分组获取新闻文章。
  • getTopNewsByCoin(coin: String, lang?: enum) 从CryptoControl API获取特定币种的顶级新闻文章。
  • getLatestNewsByCoin(coin: String, lang?: enum) 获取特定币种的最文章。
  • getTopNewsByCoinCategory(coin: String, lang?: enum) 获取特定币种按类别分组的新闻文章。
  • getTopRedditPostsByCoin(coin: String, lang?: enum) 获取特定币种的顶级Reddit帖子。
  • getLatestRedditPostsByCoin(coin: String, lang?: enum) 获取特定币种最新的Reddit帖子。
  • getTopTweetsByCoin(coin: String, lang?: enum) 获取特定币种的顶级推文。
  • getLatestTweetsByCoin(coin: String, lang?: enum) 获取特定币种最新的推文。
  • getTopFeedByCoin(coin: String, lang?: enum) 获取特定币种的综合源(Reddit/推文/文章)(按时间排序)。
  • getLatestFeedByCoin(coin: String, lang?: enum) 获取特定币种的综合源(Reddit/推文/文章)(按相关性排序)。
  • getTopItemsByCoin(coin: String, lang?: enum) 获取特定币种的Reddit/推文/文章(分开)(按时间排序)。
  • getLatestItemsByCoin(coin: String, lang?: enum) 获取特定币种的Reddit/推文/文章(分开)(按相关性排序)。
  • getCoinDetails(coin: String) 获取特定币种的全部详细信息(链接、描述、subreddits、twitter等..)
  • enableSentiment() 获取情感数据点

lang 允许开发者选择他们想要的获取源的语言。目前CryptoControl API支持以下语言

  • 英语 (en 默认)
  • 中文/普通话 (cn)
  • 德语 (de)
  • 意大利语 (it)
  • 日语 (jp)
  • 韩语 (ko)
  • 葡萄牙语 (po)
  • 俄语 (ru)
  • 西班牙语 (es)

币种缩写是来自CoinMarketCap API使用的币种ID。您可以在以下位置查看完整的币种列表:https://api.coinmarketcap.com/v1/ticker/?limit=2000

enableSentiment() 将指示CryptoControl返回包含情感数据点的文章/Reddit/Twitter(即文章有多正/负)。此功能仅适用于CryptoControl高级用户

[{
    "hotness": 70862.60323026273,
    "activityHotness": 4.601980262729618,
    "primaryCategory": "General",
    "words": 1444,
    "similarArticles": [
        {
            "_id": "5b363b525b113200191a1d5f",
            "publishedAt": "2018-06-29T13:42:44.000Z",
            "title": "Op-Ed: Challenge of Mining Centralization Unveils Bitcoin’s Elegant Design",
            "url": "https://cryptocontrol.io/r/api/article/5b363b525b113200191a1d5f?ref=5ac11440ec0af7be35528459",
            "source": {
                "_id": "59d8c361ef8bf95cc2bfb66f",
                "name": "Bitcoin Magazine",
                "url": "https://bitcoinmagazine.com/"
            },
            "sourceDomain": "bitcoinmagazine.com",
            "thumbnail": null
        },
        {
            "_id": "5b3865405c5681000f2f7407",
            "publishedAt": "2018-06-30T14:58:00.000Z",
            "title": "Arbitration on a Governed Blockchain: EOS’ Crisis of Dispute Resolution",
            "url": "https://cryptocontrol.io/r/api/article/5b3865405c5681000f2f7407?ref=5ac11440ec0af7be35528459",
            "source": {
                "_id": "59d70be3ef8bf95cc2aa2b4f",
                "name": "CoinTelegraph",
                "url": "https://cointelegraph.com/"
            },
            "sourceDomain": "cointelegraph.com",
            "thumbnail": null
        }
    ],
    "coins": [
        {
            "_id": "59cb59f9b0836b0a63aebc7c",
            "name": "Ethereum",
            "tradingSymbol": "eth",
            "slug": "ethereum"
        },
        {
            "_id": "59d21e9b83a0523906a45dc5",
            "name": "EOS",
            "slug": "eos",
            "tradingSymbol": "eos"
        }
    ],
    "_id": "5b3a2e1b104844000fd64e28",
    "description": "The EOS governance disaster offers a strong reminder of how entrenched human mistrust can be difficult to overcome.",
    "publishedAt": "2018-07-02T12:00:27.000Z",
    "title": "It's Too Soon for On-Chain Governance - CoinDesk",
    "url": "https://cryptocontrol.io/r/api/article/5b3a2e1b104844000fd64e28?ref=5ac11440ec0af7be35528459",
    "source": {
        "_id": "59ce11393a44cf289a9a71f5",
        "name": "CoinDesk",
        "url": "http://coindesk.com"
    },
    "thumbnail": "https://cryptocontrol.io/r/thumbnail/5b3a2e1b104844000fd64e28?ref=5ac11440ec0af7be35528459",
    "sourceName": "CoinDesk",
    "sourceUrl": "http://coindesk.com",
    "sourceDomain": "coindesk.com",
    "originalImageUrl": "https://media.coindesk.com/uploads/2018/06/shutterstock_153840266-e1530230263310.jpg"
}]