定制 rakibdevs/covid19-laravel-api 二次开发

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

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

rakibdevs/covid19-laravel-api

Composer 安装命令:

composer require rakibdevs/covid19-laravel-api

包简介

Laravel package to connect https://rapidapi.com/api-sports/api/ to get covid-19 statistics data for any location on the globe immediately

README 文档

README

Packagist GitHub stars GitHub forks GitHub issues GitHub license Twitter

Laravel Covid-19 API (covid19-laravel-api) is a Laravel package to connect Open Covid-19 APIs ( https://rapidapi.com/api-sports/api/covid-193 ) and access free API services easily.

Supported APIs

APIs Get data by
Statistics By country [optional]
Available Countries
History By country [Required], date [optional]

Installation

Install the package through Composer. On the command line:

composer require rakibdevs/covid19-laravel-api

Configuration

If Laravel > 7, no need to add provider

Add the following to your providers array in config/app.php:

'providers' => [
    // ...
    RakibDevs\Covid19\Covid19ServiceProvider::class,
],
'aliases' => [
    //...
    'Covid19' => RakibDevs\Covid19\Covid19::class,	
];

Publish the required package configuration file using the artisan command:

	$ php artisan vendor:publish

Edit the config/openCovid19.php file and modify the api_key value with your Open Covid19 Map api key.

Get an api key here

	return [
	    'api_key' 	        => ''
	];

Usage

Here you can see some example of just how simple this package is to use.

use RakibDevs\Covid19\Covid19;
use RakibDevs\Covid19\Facades\Covid;

// Get current Covid19 by city name 

// 1. The traditional way
$wt   = new Covid19();
$info = $wt->getCountries('ban');    

// 2. The Facade way
$info = Covid::getCountries('ban');

Output

{
    "get":"countries"
    "parameters":{
        "search":"ban"
    }
    "errors":[]
    "results":3
    "response":[
        0:"Albania"
        1:"Bangladesh"
        2:"Lebanon"
    ]
}

Available Countries

Get all current statistics for all countries

// By country name or portion of string
$info = $wt->getCountries('ban'); 

// Get all countries
$info = $wt->getAllCountries(); 

Output:

{
    "get":"countries"
    "parameters":[]
    "errors":[]
    "results":225
    "response":[
        0:"Afghanistan"
        1:"Albania"
        ........
    ]
}

Statistics

This endpoint reflects the current status of the spread of the coronavirus in all countries.

It is possible to filter per country to retrieve its current status.

For the current situation in the world use All

// By country name
$info = $wt->getStatistics(); 

// Get statistics
$info = $wt->getAllStatistics(); 

Output:

{
    "get":"statistics"
    "parameters":{
        "country":"bangladesh"
    }
    "errors":[]
    "results":1
    "response":[
        0:{
            "continent":"Asia"
            "country":"Bangladesh"
            "population":165545725
            "cases":{
            "new":"+692"
            "active":47562
            "critical":NULL
            "recovered":466064
            "1M_pop":"3149"
            "total":521382
        }
        "deaths":{
            "new":"+22"
            "1M_pop":"47"
            "total":7756
        }
        "tests":{
            "1M_pop":"20202"
            "total":3344399
        }
        "day":"2021-01-10"
        "time":"2021-01-10T05:30:06+00:00"
        }
    ]
}

History

This dunction refers to the entire history of statistics for a country.

For global results, use .

// By country name [required] and date
$info = $wt->getHistory('bangladesh', '2020-01-01'); 

Output

{
    "get":"history"
    "parameters":{
        "country":"Bangladesh"
        "day":"2020-06-02"
    }
    "errors":[]
    "results":1
    "response":[
        0:{
            "continent":"Asia"
            "country":"Bangladesh"
            "population":164551275
            "cases":{
                "new":"+2381"
                "active":38265
    ....

Worldwide Summary

Get Covid-19 worldwide summary till current date.

$info = $wt->getSummary();

Output

{
    "cases_new": 777635
    "cases_active": 67908362
    "cases_critical": 325531
    "cases_recovered": 193258167
    "cases_total": 270304615
    "deaths_new": 14668
    "deaths_total": 5805634
    "tests_total": 1282221510
    "time": "2020-03-25T06:00:07+00:00"
}

License

Laravel Open Covid19 API is licensed under The MIT License (MIT).

统计信息

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

GitHub 信息

  • Stars: 19
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固