Install Forest Admin on a REST API

If you're looking to use Forest Admin's powerful front-end with an existing REST API, look no further!

After signing up, create a project:

On the next screen, select the REST API option and input the base URL of your API

The base of your API is the endpoint that will allow you to both fetch your data and query your authentication endpoint. So for instance: https://mycompany/api/customers fetches your data https://mycompany/api/session authenticates your users 👉 you should use https://mycompany/api/ https://mycompany/api/customers fetches your data https://mycompany/session authenticates your users 👉 you should use https://mycompany/

Setting up your authentication

The next screen will help you set up your authentication. If your API doens't require one, just skip this step:

Otherwise select "Custom" and provide an authentication endpoint:

For now the only available authentication method does the following:

  • query the authentication endpoint which returns a token

  • use this token in a Bearer header to authenticate the calls to your API

If the payload used to get authenticate the user varies from the default one, you can change it according to your needs. For instance:

$login and $password must be included at all times, because both are required to authenticate the user. If one of them isn't detected, you will get an error:

Lastly, the response from your authentication endpoint should be a json payload containing a token to authenticate the user on their subsequent resquests. Please provide the path to this token.

Adding your first collection

Adding the very first collection is mandatory before you can proceed to your admin panel:

Once you have filled the Collection name and the Endpoint, click on Test so that we can display the data received.

The Result data output must be an array of objects that cointain an id. If the Data received from your endpoint has a different structure, modify the return data function to adjust the output and click on Test again. Once the Result data output is accepted like on the above screenshot, click Create collection.

Congratulations! You may now start to customize your interface using the Layout Editor or complete other methods of this collection, like explained below.

Completing all methods of a collection

If you trigger an action or try to access a view that requires more setup, you will be prompted to access your Project settings:

In your Project settings, go to the REST API tab.

On this page, you'll be able to set up all your endpoints required for the full Forest Admin experience:

Limitations

Pagination, Filtering, Sorting and Segments

We have yet to implement this. In future versions, you'll be able to make use of our query params in your endpoint to return paginated/filtered data. In the meantime, you can display more records by tweaking your numbers of records per page.

Roles

Roles are usable but for structural reasons only protect you in the frontend.

Environments

For now you can only show data in one environment, so we recommend using your production data so that it's meaningful. In later iterations, we may add the possibillity of managing multiple environments each using different endpoints.

Scopes

This feature is disabled for now as it relies on filtering which is not yet supported.

Smart actions

This feature is disabled for now.

Smart views

This feature is disabled for now.