PHPackages                             needlaravelsite/tikapi-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. needlaravelsite/tikapi-php

ActiveLibrary[API Development](/categories/api)

needlaravelsite/tikapi-php
==========================

TikAPI SDK for plain PHP and Laravel — created by NeedLaravelSite

v1.0.1(6mo ago)17255—0%1MITPHPPHP &gt;=8.0

Since Nov 2Pushed 6mo agoCompare

[ Source](https://github.com/needlaravelsite/tikapi-php)[ Packagist](https://packagist.org/packages/needlaravelsite/tikapi-php)[ RSS](/packages/needlaravelsite-tikapi-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

needlaravelsite/tikapi-php
==========================

[](#needlaravelsitetikapi-php)

TikAPI SDK for **plain PHP** and **Laravel**, created and maintained by **NeedLaravelSite**.

---

🚀 Overview
----------

[](#-overview)

This SDK provides a clean, scalable, and framework-agnostic wrapper for the [TikAPI](https://www.tikapi.io/documentation/) — making it easy to fetch TikTok data via PHP or Laravel.

✅ Works in **plain PHP**
✅ Fully integrated with **Laravel** (Service Provider + Facade)
✅ Built on **Guzzle**
✅ Auto-loads API keys from `.env`
✅ **PSR-4** and **PSR-12** compliant
✅ Includes **feature tests** for all public endpoints

---

🧰 Installation
--------------

[](#-installation)

```
composer require needlaravelsite/tikapi-php
```

> Requires **PHP 8.0+**

---

⚙️ Laravel Setup
----------------

[](#️-laravel-setup)

### 1. Publish Configuration

[](#1-publish-configuration)

```
php artisan vendor:publish --provider="NeedLaravelSite\\TikApi\\TikApiServiceProvider" --tag=config
```

### 2. Add Environment Variables

[](#2-add-environment-variables)

```
TIKAPI_API_KEY=your_api_key_here
TIKAPI_ACCOUNT_KEY=your_account_key_if_any
TIKAPI_BASE_URL=https://api.tikapi.io
```

If any of these values are missing, the SDK safely defaults to environment values or fallback URLs.

---

🧱 Project Structure
-------------------

[](#-project-structure)

```
src/
├── Client/
│   └── HttpClient.php
├── Endpoints/
│   └── Public/
│        ├── Check.php
│        ├── CommentReplies.php
│        ├── Comments.php
│        ├── Explore.php
│        ├── Followers.php
│        ├── Following.php
│        ├── Hashtag.php
│        ├── Likes.php
│        ├── Music.php
│        ├── MusicInfo.php
│        ├── Posts.php
│        ├── Search.php
│        └── Video.php
├── Exceptions/
│   └── TikApiException.php
├── Facades/
│   ├── TikApi.php
│   └── TikApiServiceProvider.php
└── TikApi.php

```

---

🧩 Usage Examples
----------------

[](#-usage-examples)

### ✅ In Laravel (via Facade or DI)

[](#-in-laravel-via-facade-or-di)

**Using the Facade:**

```
use NeedLaravelSite\TikApi\Facades\TikApi;

$response = TikApi::public()->explore()->list(5, 'us');
```

**Using Dependency Injection:**

```
use NeedLaravelSite\TikApi\TikApi;

class TikApiController
{
    public function index(TikApi $tikapi)
    {
        return $tikapi->public()->video()->get('7109178205151464746');
    }
}
```

---

### ✅ In Plain PHP

[](#-in-plain-php)

```
