skizu/simpleapi

Simple api wrapper with easy caching and throttling
170 2
Install
composer require skizu/simpleapi
PHP:>=5.4.0
License:MIT
Last Updated:Mar 7, 2016
Links: GitHub  ·  Packagist
Maintainer: Skizu

SimpleAPI for Laravel 4 and 5

A simple api wrapper with quick and easy caching and throttling.

Configuration

To configure a new api key you must register it in the .env where in the example EXAMPLE_KEY is the key.

# Required 
EXAMPLE_KEY_API_URL=http://api.example.com/

# Optional
EXAMPLE_KEY_API_THROTTLE_LIMIT=100
EXAMPLE_KEY_API_STORAGE_TIME=1440
EXAMPLE_KEY_API_CACHE_TIME=60

Usage

Example to resolve http://api.example.com/baz?foo=bar

$api = new SimpleAPI\RegisterAPI('example_key');

$query = [
	'foo' => 'bar'
];

$result = $api->action('baz')->lookup($query);

Error handling

This library works by throwing exceptions which you would need to catch.

  • Invalid configuration ConfigException
  • Throlled API ThrottleException
  • Request error RequestException
  • Response error ResponseException
  • Server error ServerException

Related Packages

skizu/freshdeskreporting

A way to collect and report on Freshdesk tickets

25 0
php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,305 162
wtfzdotnet/tmdb-package

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

492 162
solvire/php-hypermedia-api

PHP Hypermedia Enabled API Wrapper for HTTP REST

61 14
braseidon/steam-inventory-laravel

SteamInventory is a wrapper around the JSON Steam API that grabs a user's items...

34 10