PHP Client around Big Huge Thesaurus API

v1.1.0 2021-01-21 15:55 UTC

This package is auto-updated.

Last update: 2021-04-21 16:31:25 UTC


Latest Version on Packagist Software License Total Downloads

PHP Wrapper for the Big Huge Labs Thesaurus API.


Via Composer

$ composer require mettle/big-huge-thesaurus-client


$API_KEY = 'Get an api key @';

$client = new Mettleworks\BigHugeThesaurusClient\BigHugeThesaurusClient($API_KEY);
$response = $client->lookup('love');

The response object is an instance of ThesaurusResponse, an object that wraps the original response and adds a few convenience methods. You can optionally pass an argument to each method to indicate if you want only nouns (noun), verbs (verb), adjectives (adjective) or adverbs (adverb) otherwise they will return all results combined. The signature of the methods is the following:

 * Get the synonyms from the response
$response->getSynonyms($type = null): array

 * Get the antonyms from the response
$response->getAntonyms($type = null): array

 * Get the similar terms from the response
$response->getSimilarTerms($type = null): array

 * Get related terms from the response
$response->getRelatedTerms($type = null): array

 * Cast response to array (returns the original response)
$response->toArray(): array

 * Cast response to JSON

The client throws specific exceptions when an error occurs. Those errors are documented on the Big Huge Thesaurus Api Page.

try {
    $response = $client->lookup('love');
} catch (NotFoundException $ex) {
    // Not Found
} catch (UsageExceededException $ex) {
    // Usage exceeded
} catch (InactiveKeyException $ex) {
    // Key not active
} catch (MissingWordsException $ex) {
    // No words provided
} catch (NotWhitelistedException $ex) {
    // IP address blocked

Additionally if an error occurs outside the listed ones, the original Guzzle Exception is thrown.


$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.