PHPackages                             kalimeromk/semrush-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. kalimeromk/semrush-api

ActiveLibrary[API Development](/categories/api)

kalimeromk/semrush-api
======================

Framework-agnostic PHP SDK for SEMrush API v3/v4 - Analytics, Trends, Projects, and Local API

v1.0(3mo ago)1399MITPHPPHP ^8.0

Since Mar 12Pushed 2mo agoCompare

[ Source](https://github.com/KalimeroMK/SEMrush)[ Packagist](https://packagist.org/packages/kalimeromk/semrush-api)[ RSS](/packages/kalimeromk-semrush-api/feed)WikiDiscussions main Synced 3w ago

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

SEMrush API PHP SDK
===================

[](#semrush-api-php-sdk)

[![PHP Version](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Framework-agnostic PHP SDK for SEMrush API v3/v4 - Analytics, Trends, Projects, and Local API.

Features
--------

[](#features)

- 🔌 **Framework Agnostic** - Works with Laravel, Yii2, Symfony, or plain PHP
- 📊 **Analytics API v3** - Domain, Keyword, Backlink, and URL reports
- 📈 **Trends API** - Traffic and market data analysis
- 🔧 **Projects API** - Site Audit and Position Tracking
- 📍 **Local API** - Listing Management and Map Rank Tracker
- 🔄 **Multiple Auth Methods** - API Key (v3) and OAuth2 (v4)
- 📝 **CSV &amp; JSON Support** - Automatic parsing based on endpoint
- 🛡️ **Error Handling** - Custom exceptions for API errors

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

[](#installation)

```
composer require kalimeromk/semrush-api
```

Quick Start
-----------

[](#quick-start)

```
use Kalimeromk\SemrushApi\Auth\ApiKeyAuthentication;
use Kalimeromk\SemrushApi\Client\SemrushClient;

// Initialize with API Key
$auth = new ApiKeyAuthentication('your_api_key');
$client = new SemrushClient($auth);

// Get domain organic keywords
$keywords = $client->analytics()->domainOrganic('example.com', 'us', [
    'display_limit' => 10,
]);

foreach ($keywords as $keyword) {
    echo $keyword['Ph'] . ' - Position: ' . $keyword['Po'] . "\n";
}
```

Framework Integration
---------------------

[](#framework-integration)

- [Laravel Integration Guide](docs/laravel-integration.md)
- [Yii2 Integration Guide](docs/yii2-integration.md)
- [Symfony Integration Guide](docs/symfony-integration.md)

### Quick Example

[](#quick-example)

```
// Laravel
class SeoController extends Controller
{
    public function __construct(private SemrushClient $semrush) {}

    public function index()
    {
        $data = $this->semrush->analytics()->domainOverview('example.com');
        return view('seo.report', compact('data'));
    }
}

// Yii2
$keywords = Yii::$app->semrush->analytics()->domainOrganic('example.com');

// Symfony
public function index(SemrushClient $semrush)
{
    $data = $semrush->analytics()->domainOverview('example.com');
    return $this->json($data->toArray());
}
```

API Reference
-------------

[](#api-reference)

### Analytics API

[](#analytics-api)

```
// Domain Overview
$client->analytics()->domainOverview('example.com', 'us');
$client->analytics()->domainRank('example.com', 'us'); // Single database
$client->analytics()->domainRankHistory('example.com', 'us'); // Historical data

// Organic Keywords
$client->analytics()->domainOrganic('example.com', 'us', [
    'display_limit' => 100,
    'export_columns' => 'Ph,Po,Nq,Cp,Ur,Tr',
]);

// Paid Keywords
$client->analytics()->domainAdwords('example.com', 'us');

// Keyword Research
$client->analytics()->keywordOverview('seo tools', 'us');
$client->analytics()->relatedKeywords('seo tools', 'us', 10);
$client->analytics()->keywordDifficulty('seo tools', 'us');
$client->analytics()->phraseQuestions('seo tools', 'us'); // Question keywords
$client->analytics()->phraseFullsearch('seo tools', 'us'); // Full search keywords

// Winners & Losers
$client->analytics()->rankDifference('us'); // Domains that gained/lost most

// Backlinks
$client->analytics()->backlinksOverview('example.com');
$client->analytics()->backlinks('example.com');
$client->analytics()->referringDomains('example.com');
$client->analytics()->backlinksTld('example.com'); // TLD distribution
$client->analytics()->backlinksGeo('example.com'); // Geographic distribution
$client->analytics()->backlinksCompetitors('example.com'); // Similar link profiles
$client->analytics()->backlinksHistorical('example.com'); // Historical trends
$client->analytics()->backlinksComparison(['example.com', 'competitor.com']); // Batch compare
$client->analytics()->backlinksAscoreProfile('example.com'); // Authority Score distribution
$client->analytics()->backlinksCategories('example.com'); // Domain categories
$client->analytics()->backlinksCategoriesProfile('example.com'); // Category profile

// URL Reports
$client->analytics()->urlOrganic('https://example.com/page', 'us');

// Keyword Gap Analysis
$client->analytics()->keywordGap(['domain1.com', 'domain2.com'], 'us');
```

### Trends API

[](#trends-api)

```
// Traffic Summary
$client->trends()->summary('example.com', '2024-01-01', 'US');

// Traffic Sources
$client->trends()->trafficSources('example.com', 'US');

// Geographic Distribution
$client->trends()->geoDistribution('example.com');

// Audience Insights (Premium)
$client->trends()->audienceInsights('example.com');
$client->trends()->ageSexDistribution('example.com');
```

### Projects API

[](#projects-api)

```
// List projects
$client->projects()->listProjects();

// Get project
$client->projects()->getProject($projectId);

// Create project
$client->projects()->createProject('My Project', 'example.com');

// Site Audit
$client->projects()->listSiteAudits($projectId);
$client->projects()->getSiteAuditHistory($projectId);

// Position Tracking
$client->projects()->listPositionTracking($projectId);
$client->projects()->getRankings($projectId, $campaignId);
```

### Local API (OAuth2)

[](#local-api-oauth2)

```
use Kalimeromk\SemrushApi\Auth\OAuth2Authentication;

$oauth = new OAuth2Authentication('access_token');
$client = new SemrushClient($oauth);

// Listing Management
$client->local()->getLocations();
$client->local()->getLocation($locationId);
$client->local()->updateLocation($locationId, [...]);

// Map Rank Tracker
$client->local()->getMapRankCampaigns();
$client->local()->getMapRankKeywords($campaignId);
$client->local()->getMapRankHeatmap($campaignId, $keywordId);
```

Error Handling
--------------

[](#error-handling)

```
use Kalimeromk\SemrushApi\Exceptions\RateLimitException;
use Kalimeromk\SemrushApi\Exceptions\AuthenticationException;

try {
    $data = $client->analytics()->domainOrganic('example.com');
} catch (RateLimitException $e) {
    // Handle rate limit
    $retryAfter = $e->getRetryAfter();
} catch (AuthenticationException $e) {
    // Handle auth error
} catch (\Kalimeromk\SemrushApi\Exceptions\SemrushApiException $e) {
    // Handle API error
    echo $e->getMessage();
    echo $e->getHttpCode();
    echo $e->getResponseBody();
}
```

Response Handling
-----------------

[](#response-handling)

```
$response = $client->analytics()->domainOrganic('example.com');

// As array
$array = $response->toArray();

// As JSON string
$json = $response->toJson();

// Iterate results
foreach ($response as $item) {
    echo $item['Ph']; // Keyword phrase
}

// Get first result
$first = $response->first();

// Check count
$count = $response->count();
```

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run unit tests only
composer test:unit

# Run integration tests (requires API key)
composer test:integration
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file.

Support
-------

[](#support)

For issues and feature requests, please use [GitHub Issues](https://github.com/kalimeromk/semrush-api/issues).

---

**Note:** This package is not affiliated with or endorsed by SEMrush. SEMrush is a trademark of SEMrush Inc.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

104d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/472c4da0220f15747dd81d3a27ffbba022a06ab20f64a367ddcaacd790d812d7?d=identicon)[KalimeroMK](/maintainers/KalimeroMK)

---

Top Contributors

[![KalimeroMK](https://avatars.githubusercontent.com/u/24772657?v=4)](https://github.com/KalimeroMK "KalimeroMK (2 commits)")

---

Tags

apilaravelsdkyiianalyticsseoSEMRush

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kalimeromk-semrush-api/health.svg)

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

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35729.6k2](/packages/telnyx-telnyx-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k26.1M294](/packages/openai-php-client)[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60315.4M74](/packages/mollie-mollie-api-php)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.6M46](/packages/getbrevo-brevo-php)[square/square

Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.

763.7M26](/packages/square-square)

PHPackages © 2026

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