mjf9999 / redash-api-client
re:dash results API client for PHP.
1.0.4
2023-11-01 03:30 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.2|^6.3|^7.0
- jms/serializer: ^1.1
README
re:dash results API client for PHP.
Installaton
$ composer require mjf9999/redash-api-client
Usage
<?php require __DIR__ . '/../vendor/autoload.php'; define('REDASH_URL', 'http://localhost:5000/'); define('REDASH_QUERY_API_KEY', 'REDASH_QUERY_API_KEY'); define('REDASH_USER_API_KEY', 'REDASH_USER_API_KEY'); define('REDASH_QUERY_ID', 1); // Fetch data without refresh option. // You can fetch data without User API Key. $client = new RedashApiClient\Client(REDASH_URL); $client->fetch(REDASH_QUERY_ID, REDASH_QUERY_API_KEY, false, [], function (array $row, array $columns) { $row = array_map(function ($column) use ($row) { return $row[$column]; }, $columns); echo implode("\t", $row) . PHP_EOL; }); // Fetch data with refresh option. // When you want to fetch data with refresh option, You have to use User API Key. $client = new RedashApiClient\Client(REDASH_URL, REDASH_USER_API_KEY); $client->fetch(REDASH_QUERY_ID, null, true, ['yearmonth' => '2023-07'], function (array $row, array $columns) { $row = array_map(function ($column) use ($row) { return $row[$column]; }, $columns); echo implode("\t", $row) . PHP_EOL; });
License
MIT