Generating APIs

Automatically generating APIs for a relational database.

Generate APIs for Database Table

One option when creating an API is to have the API Express automatically generate the APIs for a relational database. With this option, you can quickly generate services that:

  • Find
  • Get
  • Create
  • Delete
  • Update

📘

Generating APIs

Automatically generating APIs works with a relational database. To connect to another data sources or write a custom SQL query, use the visual service creator.

📘

Database connection

A database connection is required before you can generate REST APIs. Learn how to create a database connection.

To start generating APIs follow the steps below.

🚧

Primary key

Your database table must have one primary key. A tables with more than one primary keys are not currently supported.

  1. Click the new service link.
  2. Select the first option: Generate REST API (this should be selected by default).
  3. Enter the API endpoint name. This string will be part of the API URL.
  4. Enter an optional (recommended) description.
  5. Next select a database connection. By default all appery.io databases are available with predefined prefix [appery.io].
  6. Next select a table.

Once your table is selected, the API Express will display the services and it will generate in the Actions section. You can generate the following API services:

  • FIND
  • GET
  • CREATE
  • DELETE
  • UPDATE

Below the Actions section you will see a table, which shows the columns information from the database table.

Generating APIs for a database.Generating APIs for a database.

Generating APIs for a database.

How SQL Operations Map to HTTP Method

This is how database operations match to HTTP methods:

Operation

SQL

HTTP

Create

INSERT

POST, PUT

Read (retrieve), Find

SELECT

GET

Update (modify)

UPDATE

PUT, PATCH

Delete (remove)

DELETE

DELETE

Now, you can test all the created services. All information about testing, you can find here: Testing APIs created in API Express.

Actions and HTTP Methods

The following table will give you a general overview of using POST, GET, PUT and DELETE methods and show when to use which method:

Resource

POST

GET

PUT

DELETE

/accounts

Creates a new account.

Lists all accounts.

Doesn't work. PUT works with a particular object (account), not all the objects.

Doesn't work. DELETE works with a particular object (account), not all the objects.

/account/123

Doesn't work. POST works when creating a new object (account), not working with an existing object.

Returns account 123.

Updates account 123.

Deletes account 123.

Available Parameters

To learn about parameters available for each action, please go to Testing page.

Examples