This Bundle provides everything you need to interact with web API. It's object-oriented, simple and powerful.

1.0.0 2014-03-27 07:12 UTC


MiniApi is an object oriented and flexible API client which contains everything you need to interact with web API.


  • Support standard HTTP protocols: GET, POST, PUT, DELETE, HEAD, OPTIONS;
  • Support SOAP protocol
  • Support WSSE authentication


composer require miniapi/miniapi

Get Started

  • Initialization

      $api = new MiniApi\MiniApi();
  • Simple GET request

  • Simple POST request

      $api->post('')->call('{"name", "John"}')->debug();
  • POST with WSSE authentication

      $response = $api->post('', '/user')
      	->prop('wsse.username', 'example-username')
      	->prop('wsse.password', 'example-password')
      echo $response->body();
  • SOAP with WSSE authentication

      $response = $api->soap('', 'User.New')
      	->prop('wsse.namespace', '')
      	->prop('wsse.username', 'example-username')
      	->prop('wsse.password', 'example-password')
      echo $response->body();

For more code examples, please refer to examples.


Protocol Interface
GET $api->get($endpoint, $method='')
POST $api->post($endpoint, $method='')
PUT $api->put($endpoint, $method='')
DELETE $api->delete($endpoint, $method='')
HEAD $api->head($endpoint, $method='')
OPTIONS $api->options($endpoint, $method='')
SOAP $api->soap($endpoint, $method)
User-defined $api->request($endpoint, $method, $protocol)

Each interface above returns a instance of MiniRequest which allows you to do customization using chaining methods, as you already see.

The request will NOT be sent until you use $api->call() method which accepts an optional body and returns a instance of MiniResponse.

Response Handling

MiniResponse contains all detailed information about this API call. Below is an example of response handling.

	echo sprintf("Error: %d %s\n%s", 
	echo sprintf("Response: %s\n%s\n%s", 

To save your time, you can also simply use echo $response->debug() to print out detailed request and response.

Need More Protocols/Authentications?

If you need to use some protocol/authentication that MiniApi currently doesn't support, you can write and register your own protocol handler to extend MiniApi.

class MySoapClient extends MiniProtocol{
	protected function init_auth_registration(){}
	protected function send(MiniRequest $request, MiniResponse $response){
		echo "MySoapClient is sending request ...\n";
$api->register_protocol('SOAP', 'MySoapClient');
$api->request('', 'User.New', 'SOAP')->call('{"name":"John"}');