Skip to content

API Configuration

Erik Campobadal edited this page Sep 13, 2016 · 2 revisions

API Configuration

Important Note

The Laralum's API is currently public, as we do not recommend it to have it enabled on production, we still give it a go while we design the user api keys system

Configuration

The configuracion is found in app/Http/Controllers/Laralum/Data/API.php

This configuration is used to determine what tables are going to be shown and how are they gonan be displayed. An example configuration can be found here:

 'users' => [
        'show' => [
            'id', 'name', 'email', 'active', 'banned', 'country_code', 'created_at', 'updated_at'
        ],
        'enabled' => true,
    ],

users is the table name

show is the fields that will be shown from the table rows

enabled determines if it's enabled or not

Usage

The API routes work like the following:

http://mywebsite.com/api/{table}
http://mywebsite.com/api/{table}/latest
http://mywebsite.com/api/{table}/latest/{number}
http://mywebsite.com/api/{table}/{accessor}/{data}

Once the table has been added to the configuration array you have access to all of this routes where the {accessor} is any column and the {data} the accesor's filter.

For example if you want to get all the users who's name is "Erik" and you have enabled the table like in the example:

http://mywebsite.com/api/users/name/Erik

This will return all the users found where the name is Erik

Clone this wiki locally