PHP Classes


Recommend this page to a friend!
  Classes of Thierry Feuzeu   Polr Restful API   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Polr Restful API
Provide an API for the Polr URL shortener service
Author: By
Last change: Updated the README.
Date: 5 years ago
Size: 1,697 bytes


Class file image Download

Polr API

A Restful API for the Polr URL Shortener


This package gives access to all Polr features through a Restful API, excepted the following.

  • User creation and deletion.
  • Password change.
  • Link redirection.


Add the Github repository and package to the composer.json file of your Polr installation, and run composer update.

    "repositories": [
            "type": "git",
            "url": ""
    "require": {
        "lagdo/polr-api": "dev-master"

Register the service provider in the bootstrap/app.php.



The API endpoints are documented here. The documentation is generated with API Doc.

Known issues

Sometimes the requests to the API return with errors due to CSRF verification failure. That's because Polr has disabled CSRF verification only for its own API endpoints.

This API endpoints then need to be also added in the app/Http/Middleware\VerifyCsrfToken.php file.

    public function handle($request, \Closure $next) {
        if ($request->is('api/v/action/') ||
            $request->is('api/v/data/') ||
            $request->is('api/v/links/') ||
            $request->is('api/v/users/') ||
            $request->is('api/v/stats/')) {
            // Exclude public API from CSRF protection
            // but do not exclude private API endpoints
            return $next($request);

        return parent::handle($request, $next);