This project is a Twitch API developed in PHP
using the Laravel
framework and Docker
for containerization. It adheres to Clean Code principles, includes comprehensive testing, and incorporates regular code refactoring to maintain high code quality. The API provides the following endpoints:
/streamers:id (
GET
): Retrieves data for a given Twitch streamer by id.curl -X GET 'http://localhost/analytics/streamers?id=459331509'
/streams (
GET
): Obtains live Twitch streams.curl -X GET 'http://localhost/analytics/streams'
/topsofthetops:since (
GET
): Retrieves data for the top 40 videos of each of the top three most popular games, with an optional integer parametersince
to filter results based on time (seconds).curl -X GET 'http://localhost/analytics/topsofthetops'
curl -X GET 'http://localhost/analytics/topsofthetops?since=150'
/timeline:username (
GET
): Retrieves the list of recent streams from followed streamers.curl -X GET 'http://localhost/analytics/timeline?username=user_name'
/follow (
POST
): Allows registered users to follow a streamer.curl -X POST 'http://localhost/analytics/follow' \ -H "Content-Type: application/json" \ -d '{"username": "user_name", "streamerId": "streamer_id"}'
/unfollow (
DELETE
): Allows registered users to unfollow a streamer.curl -X DELETE 'http://localhost/analytics/unfollow' \ -H "Content-Type: application/json" \ -d '{"username": "user_name", "streamerId": "streamer_id"}'
/users (
POST
): Creates a new user with a specified username.curl -X POST 'http://localhost/analytics/users' \ -H "Content-Type: application/json" \ -d '{"username": "user_name", "password": "password"}'
/users (
GET
): Retrieves a list of all registered users, including the streamers each user follows.curl -X GET 'http://localhost/analytics/users'
git clone [email protected]:sayechu/laravel-twitch-api.git
cd laravel-twitch-api
composer install
cp .env.example .env
Note I: alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'
Note II: run Docker Desktop before executing this command
sail up -d
sail php artisan migrate
sail down
./vendor/bin/phpunit
sail php artisan migrate:rollback