DecAPI started out as an API designed primarily for Twitch chatbots that supported sending requests to external APIs.
These chatbots would send requests to the APIs and then just return the response directly, which is the whole reason DecAPI mainly responds in plaintext.
While the primary usage of DecAPI is still related to Twitch chatbots, it's also used by other developers for stream overlays, websites etc.
Even though I generally allow everyone to rely on DecAPI for their data, I still recommend relying on the direct APIs whenever possible.
DecAPI is a personal project I started writing in 2014 (V1), which eventually became a big pile of undocumented, and badly written mess.
The current version of DecAPI (V2) was started in early 2016 and is an attempt to rewrite the codebase, while also keeping backwards compatibility, but also have it somewhat structured (unlike V1).
V2 is based on the Laravel framework.
The CONTRIBUTING
document has been moved to .github/CONTRIBUTING.md
The layout of the application can be reflected upon by looking at the routes/web.php file. Each group uses their own controller located in app/Http/Controllers, and each sub-route usually has their own method in said controller.
The standard layout will be https://example.com/main-route/sub-route/parameter
- where parameter
can be something like the channel name.
To keep it backwards compatible, routes also support /main-route/sub-route?channel=decicus
or /main-route/sub-route.php?channel=decicus
.
The following things are required for setting this up:
I only recommend setting this up for development purposes.
.env.example
to .env
and fill in the information in the .env
file. Primarly the database and Twitch information.
APP_DEBUG
value to false
to not leak any credentials.http://your.url/auth/twitch/callback
and TWITCH_REDIRECT_URI
in the .env
file has to be set to the same URL.PAPERTRAIL_LOG_DESTINATION
to whatever Papertrail gives you that's in the logsX.papertrailapp.com:YYYY
format.
X
and YYYY
are numbers, and are just placeholders.composer install
in the project directory.php artisan key:generate
from the command line in the base project directory, to generate the application key.php artisan migrate
from the command line in the base project directory./public
directory of the repo.
AllowOverride
to All
for the specific directory in the vhost, so the .htaccess
file can set the settings.* * * * * php /path/to/decapi/artisan schedule:run >> /dev/null 2>&1
.
app/Console/Kernel.php
.Documentation is currently work in progress and can be found here:
If you find a bug or an issue, please create an issue in this repository.
If it's a security issue and you'd like to contact me privately, please send me an email at alex@thomassen.xyz.
Certain routes may have rate limiting applied to them to prevent abuse or to make sure DecAPI doesn't get blocked by the API provider.
The rate limits are set to something I consider "fair". Which primarily means they are set to something that should not hinder the normal user, but also should not allow them to go spam requests for no good reason.
Rate limiting is done by using Laravel's throttle
middleware. This means you can check HTTP headers sent with the request to figure out information about your rate-limit:
X-RateLimit-Limit
- How many requests per 1 minute (60 seconds) is allowed.X-RateLimit-Remaining
- How many requests you have left for this time period.Retry-After
- How many seconds until you can make requests again (Only when you have actually hit your rate limit).
429 Too many requests
HTTP status code.Below is an overview over what routes are currently rate limited. If the route is not specified, it does not have a rate limit.
Rate limits per route are separate from each other.
If you've sent 45 requests to /steam
routes, you will still have the ability to send another 100 requests to /twitch
routes.
/twitch/*
- All sub-routes under /twitch
/steam/*
- All sub-routes under /steam