The Zhylon MegAPI Client is a Laravel wrapper for MegAPI API, a platform that consolidates multiple APIs under a single API key.
Many developers struggle with managing multiple external APIs, each with its own authentication, documentation, and structure. MegAPI solves this problem by providing a unified interface where you only need one API key to access multiple services.
Why use MegAPI?
- One API key for all services
- Centralized API interface with a consistent structure
- Seamless Laravel integration
- Flexible extension: Register and use custom endpoints
- Less authentication overhead for multiple APIs
You are free to use this package, but please note that you need an active account on MegAPI to use the service.
The MegAPI is a service by Zhylon.net. It includes a lot of API Endpoints to other services. It allows you to call all those services with just one API key.
This packages does not provide any endpoints, it's just a wrapper for the API.
You can install the package via Composer:
composer require zhylon/megapi-clientYou can publish the config file with:
php artisan vendor:publish --provider="Zhylon\MegapiClient\MegApiServiceProvider" --tag="config"This is the contents of the published config file:
return [
'megapi' => [
'key' => env('MEGAPI_KEY'), // this is the key
'endpoint' => env('MEGAPI_ENDPOINT', 'https://megapi.de/api'), // this is the endpoint
],
];To register a new endpoint to the MegAPI, you can use the following code:
<?php
use Zhylon\MegapiClient\Support\Facades\MegApi;
# register a new API endpoint (we use the ServerEndpoint as example)
MegApi::register(new ServerEndpoint);
# use also could use a alias for this endpoint
MegApi::register(new ServerEndpoint, 'server');After you have registered the endpoint, you can use it like this:
# get all servers
MegApi::server('/servers', 12345678)Your ServerEndpoint should look like this:
<?php
use Zhylon\MegapiClient\MegApiEndpoint;
class ServerEndpoint implements MegApiEndpoint
{
public function handle(MegApiClient $client, ...$parameters): mixed
{
// do something with the client
}So you only have to use the MegApiEndpoint-Interface and implement the handle-Method.
After that you can use the endpoint like shown above.
Please see CHANGELOG for more information on what has changed recently.
If you've found a bug regarding security please mail security@zhylon.net instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.