Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Twitch Api Php

Twitch Api Php Laravel Package

nicklaw5/twitch-api-php

PHP client library for the Twitch API. Includes easy methods for Helix and legacy endpoints, OAuth authentication flows, and request helpers to fetch streams, users, channels, videos, clips, and more. Useful for building Twitch integrations in PHP apps.

View on GitHub
Deep Wiki
Context7

A Twitch API client for PHP.

Frequently asked questions about Twitch Api Php
How do I install this Twitch API package in a Laravel project?
Run `composer require nicklaw5/twitch-api-php` to install the package. For OAuth, pair it with `nicklaw5/twitch-auth-php` via `composer require nicklaw5/twitch-auth-php`. Configure credentials in `.env` (e.g., `TWITCH_CLIENT_ID`, `TWITCH_CLIENT_SECRET`) and bind the client to Laravel’s service container in a provider.
Does this package support Twitch’s latest Helix API and EventSub?
The package primarily covers Twitch Helix endpoints (REST) but lacks native EventSub (WebSocket) support. For real-time features, you’ll need to integrate additional libraries like `reactphp/event-loop`. Check the GitHub issues for updates on Helix alignment, as the last release was in mid-2023.
Can I use Laravel’s caching (Redis) to store Twitch API responses?
Yes. The package’s HTTP client can be configured to cache responses using Laravel’s cache system. For example, wrap API calls in `Cache::remember()` or use middleware to cache responses globally. Ensure you handle rate limits and token refreshes dynamically.
How do I integrate Twitch OAuth with Laravel Passport or Sanctum?
Use the `nicklaw5/twitch-auth-php` companion package to handle OAuth flows. Bind the auth provider to Laravel’s Passport or Sanctum in your `AuthServiceProvider`. Store Twitch tokens in the database or cache, and validate them via middleware (e.g., `auth:twitch`).
What Laravel versions does this package support, and are there breaking changes?
The package supports PHP 7.4+ and Laravel 8/9. For Laravel 10+, test compatibility due to Symfony 6+ updates. No major breaking changes are documented, but Twitch API deprecations (e.g., legacy endpoints) may require manual adjustments. Always check the changelog.
How does this package handle Twitch’s rate limits and API downtime?
The package includes built-in rate limit handling to avoid bans, but you should extend it with Laravel’s queue system for async requests (e.g., dispatch delayed jobs). For downtime, implement retry logic using Laravel’s `retry` helper or a package like `spatie/laravel-retryable`.
Can I sync Twitch data (streams, users) to Eloquent models?
Yes, the package returns structured data that you can map to Eloquent models (e.g., `Stream`, `User`). Use Laravel’s `fillable` properties and accessors to transform API responses. For example, create a `TwitchStream` model and hydrate it with data from `client->getStreams()`.
Are there alternatives to this package for Laravel Twitch integrations?
Yes, consider `spatie/twitch` for a more Laravel-centric approach, though it may lack some Helix features. For real-time EventSub, explore `php-twitch/eventsub`. Evaluate based on your needs: this package excels in REST simplicity, while alternatives may offer tighter Laravel integration or WebSocket support.
How do I test this package in a Laravel application before production?
Start with a proof-of-concept: fetch a public stream or user in a Laravel tinker session (e.g., `app(TwitchClient::class)->getStreams()`). Test OAuth flows with `nicklaw5/twitch-auth-php` and validate token storage. Use Laravel’s HTTP tests to mock API responses and simulate rate limits.
Is this package actively maintained, and how can I contribute?
The last release was in June 2023, so monitor the GitHub repo for updates. Contribute by reporting issues (e.g., Twitch API changes) or submitting PRs for Laravel-specific features like Scout integration or improved caching. Check the `CONTRIBUTING.md` for guidelines if available.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor