Git Product home page Git Product logo

apify's Introduction

Apify

API generator for Laravel 5

StyleCI StyleCI StyleCI

Apify Logo

Table Of Contents

Installation

To install apify use composer

Download

composer require consoletvs/apify

Add service provider & alias

Add the following service provider to the array in: config/app.php

ConsoleTVs\Apify\ApifyServiceProvider::class,

Publish the assets

php artisan vendor:publish

Configuration

To configure the package go to: config/apify.php

The default file have a valid example and it's documented, check it out, should look like this:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Prefix used to access the API
    |--------------------------------------------------------------------------
    */
    'prefix' => 'apify',

    /*
    |--------------------------------------------------------------------------
    | Enables or disabled the whole API endpoints
    |--------------------------------------------------------------------------
    */
    'enabled' => true,

    /*
    |--------------------------------------------------------------------------
    | The tables enabled for the api and it's columns
    |--------------------------------------------------------------------------
    */
    'tables' => [

        // Specify all the tables below

        'users' => [

            // The columns from the table that will be displayed in the JSON

            'id', 'name', 'email', 'created_at', 'updated_at'

        ],

    ],
];

Usage

Visit the endpoint like this:

Website URL + /api/ + Prefix + /{table}/{accessor?}/{data?}

table: is the table you want to look at, must be an index of the table array in the configuration.

accessor: is optional, and it's the colum to filter data.

data: is the data you're filtering, you can add multiple data separated with a ,

Note: Remember that all calls to the API goes first to the api middleware, if you need to modify the api throttle go to: App\Http\Kernel.php and modify the api throttle.

'api' => [
    'throttle:60,1',
    'bindings',
],

The 60 determines the max calls / minute.

The 1 determines the minutes to wait if the max calls are exceded.

Some examples:

http://localhost/web/Laralum3/public/api/apify/users (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"[email protected]","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":2,"name":"Second User","email":"[email protected]","created_at":"2016-09-21 16:13:28","updated_at":"2016-09-22 16:20:00"},{"id":3,"name":"Third User","email":"[email protected]","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}
http://localhost/web/Laralum3/public/api/apify/users/email/[email protected],[email protected] (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"[email protected]","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":3,"name":"Third User","email":"[email protected]","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}

apify's People

Contributors

24aitor avatar consoletvs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.