PHPackages                             r-baker/3taps-php-client - 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. r-baker/3taps-php-client

AbandonedArchivedLibrary[API Development](/categories/api)

r-baker/3taps-php-client
========================

Client library for 3taps data commons APIs (https://3taps.com). Built on top of Guzzle.

5161PHP

Since Sep 8Pushed 10y agoCompare

[ Source](https://github.com/r-baker/3taps-php-client)[ Packagist](https://packagist.org/packages/r-baker/3taps-php-client)[ RSS](/packages/r-baker-3taps-php-client/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

3taps-php-client
================

[](#3taps-php-client)

A PHP 5.3+ client for working with the [3taps](https://3taps.com) APIs. [![Build Status](https://camo.githubusercontent.com/6465e4cbfa2b2e177046470af560c601d07eac2a2d6f0eaa920fb03098162df9/68747470733a2f2f7472617669732d63692e6f72672f726a62616b65722f33746170732d7068702d636c69656e742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/r-baker/3taps-php-client)

Features
--------

[](#features)

- Built on top of the awesome [Guzzle](http://guzzlephp.org) HTTP client framework.
- Provides separate clients for the Reference, Search and Polling APIs.
- Result iterators to automatically handle result pagination, tokens, tiers and anchors.
- Include in your project using [Composer](https://packagist.org/packages/r-baker/3taps-client) or download the [zip](https://github.com/r-baker/3taps-php-client/archive/master.zip).
- Tested with PHP 5.3, 5.4 &amp; 5.5

Usage
-----

[](#usage)

### Install using Composer

[](#install-using-composer)

```
composer.phar require r-baker/3taps-php-client

```

### Create a service instance

[](#create-a-service-instance)

```
use Rbaker\ThreeTaps\ThreeTapsService;

$service = ThreeTapsService::factory(array(
	'auth_token' => 'your-private-auth-token'
));
```

### Create an API client instance (e.g. reference api)

[](#create-an-api-client-instance-eg-reference-api)

```
$referenceClient = $service->get('reference');
```

### Initiate an API request

[](#initiate-an-api-request)

```
$categories = $referenceClient->getCategories();
```

API Service Clients
-------------------

[](#api-service-clients)

All methods and parameters from each of the three APIs (as defined in the [3taps API docs](http://docs.3taps.com/)) are supported.

To use an API client, as in the example above, you must instantiate a relevant client instance from the service instance. API methods may then be called on the client instance.

If desired, an array of parameters may be passed into the second argument of an API method call. The PHP client will ensure all **required** parameters are provided, but be sure to consult the API documentation for all optional params.

### Reference

[](#reference)

The Reference API client supports the following methods:

3Taps Method NamePHP Client Method Namesources`$referenceClient->getSources()`category\_groups`$referenceClient->getCategoryGroups()`categories`$referenceClient->getCategories()`locations`$referenceClient->getLocations()`location lookups`$referenceClient->locationLookup()`#### Example:

[](#example)

```
$referenceClient = $service->get('reference');
$data = $referenceClient->locationLookup(array(
	'code'=>'USA-AL'
));
```

### Search

[](#search)

The Search API client supports the follwing methods:

3Taps Method NamePHP Client Method Namesearch`$searchClient->search()`count mode`$searchClient->count()`#### Example:

[](#example-1)

```
$searchClient = $service->get('search');
$iterator = $searchClient->getIterator('search', array(
	'category_group' => 'JJJJ'
));
$iterator->setLimit(30);
// Total number of (unlimited) results matching our request
echo $iterator->getNumMatches();
// grab results
print_r($iterator->toArray());
```

### Polling

[](#polling)

The Polling API client supports the follwing methods:

3Taps Method NamePHP Client Method Nameanchor`$pollingClient->getAnchor()`poll`$pollingClient->poll()`Please see the complete example below.

### Result Iterators

[](#result-iterators)

Result iterators automatically implement much of the logic required for working with pages of results. In the case of the 3taps Search and Polling APIs, the **page**, **anchor** and **tier** parameters are taken care of and automatically parameterized for subsequent requests. This allows you to simply set the number of results you need, and the iterator will attempt (if required) to make as many API calls as needed return your result set.

A complete example
------------------

[](#a-complete-example)

Retrieve an anchor from the polling API and poll for all job-related postings in NYC, placed in the last 3 hours.

```
