PHPackages                             silktide/brightlocal-api - 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. silktide/brightlocal-api

AbandonedArchivedLibrary[API Development](/categories/api)

silktide/brightlocal-api
========================

BrightLocal API wrapper.

0.1.5(9y ago)026GPL-3.0+PHPPHP &gt;=5.6.0

Since Jun 17Pushed 7y ago5 watchersCompare

[ Source](https://github.com/silktide/brightlocal-api)[ Packagist](https://packagist.org/packages/silktide/brightlocal-api)[ RSS](/packages/silktide-brightlocal-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (0)

brightlocal-api
===============

[](#brightlocal-api)

Wrapper for BrightLocal API. Work in progress.

[![Build Status](https://camo.githubusercontent.com/3afe17d870a052a35d16f859b1b998a42cfe35994e331a463db16f25f12a401d/68747470733a2f2f7472617669732d63692e6f72672f73696c6b746964652f6272696768746c6f63616c2d6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/silktide/brightlocal-api)[![Code Climate](https://camo.githubusercontent.com/5a99b26ec9f26bd33f6fc063ee573cf4c52629e1a294febe2a88996dba4bf1f6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696c6b746964652f6272696768746c6f63616c2d6170692f6261646765732f6770612e737667)](https://codeclimate.com/github/silktide/brightlocal-api)[![Test Coverage](https://camo.githubusercontent.com/b80f3e4698704c3cc1dee75837e79e6ef87db16e35947c113b00cb8cce3398f9/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73696c6b746964652f6272696768746c6f63616c2d6170692f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/silktide/brightlocal-api/coverage)

Methods implemented:

- Batch create
- Batch commit
- Batch get results
- Fetch profile details by business data

Create a client
---------------

[](#create-a-client)

### Using the client factory

[](#using-the-client-factory)

This library comes with a convenient factory for those not using DI. Just use the following to create an API client:

```
$clientFactory = new \Silktide\BrightLocalApi\ClientFactory();
$client = $clientFactory->createClient([YOUR API KEY], [YOUR API SECRET]);

```

### Using dependency injection

[](#using-dependency-injection)

*If you don't know what this is, ignore this part.*

If you're using [syringe](https://github.com/silktide/syringe) , a config is included for convenience. If you want to wire it up in your own DI container, take a look inside the ClientFactory class to see how the Client and its dependencies are created.

Batches
-------

[](#batches)

### Create a batch

[](#create-a-batch)

```
$batch = $client->createNewBatch();

```

### Commit batch for processing

[](#commit-batch-for-processing)

```
$batch->commit();

```

### Get results

[](#get-results)

Gets the batch results. Note - due to the way BrightLocal takes time to gather results, you may prefer to poll for results (see below).

```
$results = $batch->getResults();

```

### Poll for results

[](#poll-for-results)

As it may take time for BrightLocal to complete the batch, a convenience method will poll for results until they are available. This hangs the execution of your script until the BrightLocal results are ready. By default, the results will be checked every 5 seconds for up to 20 attempts (this can be overriden by passing values to this method). An exception will be thrown if the batch has not completed before the maximum number of attempts have been made.

```
$results = $batch->pollForResults();

```

Local directories
-----------------

[](#local-directories)

### Fetch profile details by business data

[](#fetch-profile-details-by-business-data)

```
$client->fetchProfileDetailsByBusinessData($batch, [
    'business-names' => 'Silktide',
    'country' => 'GBR',
    'city' => 'Derby',
    'postcode' => 'DE248HR',
    'local-directory' => 'google'
]);

```

The directory should be one listed in [BrightLocal's appendices](http://apidocs.brightlocal.com/#appendix). Country should be [3-letter ISO](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)

Directory config helper
-----------------------

[](#directory-config-helper)

To help with talking to the BrightLocal API, a helper is included which can help with your integration.

### Find out which directories can be used

[](#find-out-which-directories-can-be-used)

This function returns an array of directory IDs which BrightLocal supports in a given country.

```
$helper = Silktide\BrightLocalApi\Data\DirectoryConfigHelper(new Silktide\BrightLocalApi\Data\DataLoader());
$helper->getDirectoriesForCountry('GBR');

```

### Get the "friendly name" of a directory

[](#get-the-friendly-name-of-a-directory)

BrightLocal's API contains a reference to all the directories they support, but all the names are lowercase with punctuation removed (e.g. 2findlocal, canadaspace). This function returns a "friendly" name for your given directory.

```
$helper = Silktide\BrightLocalApi\Data\DirectoryConfigHelper(new Silktide\BrightLocalApi\Data\DataLoader());
$helper->getLabelForDirectory('192'); // returns '192.com'

```

Complete examples
-----------------

[](#complete-examples)

### Fetch profile details for a business

[](#fetch-profile-details-for-a-business)

```
// Create client (using factory)
$clientFactory = new \Silktide\BrightLocalApi\ClientFactory();
$client = $clientFactory->createClient([YOUR API KEY], [YOUR API SECRET]);

// Directories to fetch
$directories = [
    'google',
    'facebook',
    'yell',
    'scoot'
];

//Create batch
$batch = $client->createNewBatch();

// Add directory checks for each local directory
foreach ($directories as $directory) {
    $client->fetchProfileDetailsByBusinessData($batch, [
        'business-names' => 'Silktide\nSilktide Ltd',
        'country' => 'GBR',
        'city' => 'Derby',
        'postcode' => 'DE248HR',
        'local-directory' => $directory
    ]);
}

// Commit the batch for processing
$batch->commit();

// Poll for results
$results = $batch->pollForResults();

```

General
-------

[](#general)

### Error handling

[](#error-handling)

In the event of an issue or bad result from the API, an exception will be thrown. You should expect exceptions to be thrown in your application and handle them gracefully.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

6

Last Release

3608d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/194d1fe23e2566b3c00d0edf69239351d6c7b442abb17c8e92f8f4d1b58945af?d=identicon)[Dolondro](/maintainers/Dolondro)

![](https://www.gravatar.com/avatar/2eca248b997f71d4d1ec2059f5ab6022663ff2990c9924cdf4136784438d0971?d=identicon)[silktide](/maintainers/silktide)

![](https://www.gravatar.com/avatar/df3b84c45fff8328d8900997e87a215e1e538cfea47be8872fa1c4e35afbffbc?d=identicon)[andywaite](/maintainers/andywaite)

---

Top Contributors

[![andywaite](https://avatars.githubusercontent.com/u/6773151?v=4)](https://github.com/andywaite "andywaite (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/silktide-brightlocal-api/health.svg)

```
[![Health](https://phpackages.com/badges/silktide-brightlocal-api/health.svg)](https://phpackages.com/packages/silktide-brightlocal-api)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
