PHPackages                             rapidspike/rapidspike-api-wrapper-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rapidspike/rapidspike-api-wrapper-php

ActiveLibrary[API Development](/categories/api)

rapidspike/rapidspike-api-wrapper-php
=====================================

PHP wrapper functions for interfacing with RapidSpike's API.

v1.1.1(3y ago)14152[1 PRs](https://github.com/RapidSpike/rapidspike-api-wrapper-php/pulls)MITPHPPHP &gt;=7.0.0

Since Jun 27Pushed 3y ago2 watchersCompare

[ Source](https://github.com/RapidSpike/rapidspike-api-wrapper-php)[ Packagist](https://packagist.org/packages/rapidspike/rapidspike-api-wrapper-php)[ RSS](/packages/rapidspike-rapidspike-api-wrapper-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (9)Dependencies (1)Versions (11)Used By (0)

RapidSpike API Wrapper (PHP)
============================

[](#rapidspike-api-wrapper-php)

PHP wrapper for the [RapidSpike API](https://docs.rapidspike.com/system-api) (v1).

Information
-----------

[](#information)

RapidSpike provides a RESTful API designed to make interfacing with their services cleaner and easier. The [RapidSpike Portal](https://my.rapidspike.com) is 100% API powered so anything you can do there is possible directly via the API.

To interact with the API you must first have a RapidSpike subscription that allows access to the API. Then you need to generate API keys in your [account settings area](https://my.rapidspike.com/#/account/my-account/account-settings?tab=api).

This wrapper package is future proof as new end-points become available - it is merely a wrapper that provides a standardised way to construct end-points, package request data and authenticate in the API.

Installation
------------

[](#installation)

Recommended installation is via [Composer](https://getcomposer.org/) and [Packagist](https://packagist.org/packages/rapidspike/rapidspike-api-wrapper-php). Check the available version tags, however, development won't be overly active due to to nature of the package.

```
composer require rapidspike/rapidspike-api-wrapper-php

```

Concepts
--------

[](#concepts)

#### End-point Chaining

[](#end-point-chaining)

This wrapper package is very simple, but provides you with a standard way to call our API. End-points are built using a function-per-path segment or directly in the `callPath()` method. This makes use of magic methods so that we're future proofed against new end-points.

```
/*
 * Read account API keys
 * GET /accounts/api
 */

# Function-per-path method
$Client->accounts()->api()->via('get');

# callPath() method
$Client->callPath('accounts/api')->via('get');

```

If you need to add a value that doesn't fit into this method or is stored in a variable then the `callPath()` method is better and saves your from having to declare dynamic function names. Also, segments can be passed as parameters to segment methods:

```
/*
 * Read one website
 * GET /websites/[uuid]
 */

# Segment (UUID) stored in varibale and passed as function param
$uuid = '30031b9b-5df8-4b19-8dfe-17bf5bac7654';
$Client->websites($uuid)->via('get');

```

All requests *must* end by calling the `via()` method and passing an HTTP request verb (e.g. get, post, put, delete). Authentication is made using a pair of keys (public and private) that are required to generate a signature which is checked in the RapidSpike API.

#### Query &amp; JSON Data

[](#query--json-data)

Adding query or JSON data can be done in or before the method chain. Either way it must be done before the `via()` method:

```
/*
 * Read page 1 of all websites with 10 displayed per page
 */

# Add query data before the actual request is made
$Client->addQueryData(['page' => 1, 'per_page' => 10]);
$Client->websites()->via('get');

# Alternative; add query data whilst building the request
$Client->websites()->addQueryData(['page' => 1, 'per_page' => 10])->via('get');

```

Usage example
-------------

[](#usage-example)

Usage begins with instantiating the `RapidSpike\API\Client` object and passing your public and private keys, which are required. From there you have a number of options on how to build the end-point (see Concepts above).

```
