Magic api (transforms any Mysql database into a rest api in just 5 minutes)

fernando1987

Active Member
Licensed User
transform any database into a rest api in just 5 minutes and without programming or knowing php

instucciones:
1. create a database on your web server

2. create your tables it is important that each table created has the id field

3. upload the files inside the zip file to your server in the folder you want this would be your base url.

4. Edit the api.php file inside the core folder with your database connection details and you are ready to use your database as an api.

Example:


Download:




API Documentation​

Base URL​

Get all records from a table​

GET /api.php?table={table}
Parameters:

  • {table}: Name of the table to retrieve records from.
Successful response:

[
{
"id": 1,
"column1": "value1",
"column2": "value2",
...
},
{
"id": 2,
"column1": "value3",
"column2": "value4",
...
},
...
]

Get a record by ID​

GET /api.php?table={table}&id={id}
Parameters:

  • {table}: Name of the table to retrieve the record from.
  • {id}: ID of the record to retrieve.
Successful response:

{
"id": 1,
"column1": "value1",
"column2": "value2",
...
}

Search records by column and value​

GET /api.php?table={table}&column={column}&value={value}
Parameters:

  • {table}: Name of the table to search records in.
  • {column}: Name of the column to search.
  • {value}: Value to search for in the specified column.
Successful response:

[
{
"id": 1,
"column1": "value1",
"column2": "value2",
...
},
{
"id": 2,
"column1": "value3",
"column2": "value4",
...
},
...
]

Create a new record​

POST /api.php?table={table}
Parameters:

  • {table}: Name of the table to create a new record in.
Request body:

{
"column1": "value1",
"column2": "value2",
...
}
Successful response:

{
"id": 1,
"column1": "value1",
"column2": "value2",
...
}

Update a record by ID​

PUT /api.php?table={table}&id={id}
Parameters:

  • {table}: Name of the table to update the record in.
  • {id}: ID of the record to update.
Request body:

{
"column1": "new_value1",
"column2": "new_value2",
...
}
Successful response:

{
"response": "Record(s) updated successfully"
}

Update a record by column and value​

PUT /api.php?table={table}&column={column}&value={value}
Parameters:

  • {table}: Name of the table to update the record in.
  • {column}: Name of the column to search.
  • {value}: Value to search for in the specified column.
Request body:

{
"column1": "new_value1",
"column2": "new_value2",
...
}
Successful response:

{
"response": "Record(s) updated successfully"
}

Delete a record by ID​

DELETE /api.php?table={table}&id={id}
Parameters:

  • {table}: Name of the table to delete the record from.
  • {id}: ID of the record to delete.
Successful response:

{
"response": "Record(s) deleted successfully"
}

Delete a record by column and value​

DELETE /api.php?table={table}&column={column}&value={value}
Parameters:

  • {table}: Name of the table to delete the record from.
  • {column}: Name of the column to search.
  • {value}: Value to search for in the specified column.
Successful response:

{
"response": "Record(s) deleted successfully"
}
 

Attachments

  • 66.png
    66.png
    103.8 KB · Views: 179
Last edited:

fernando1987

Active Member
Licensed User
All the source codes and libraries of the store until the last day of the month of November will be at a 50% discount with the following coupon:

B4XSTORE50

 

Mashiane

Expert
Licensed User
Longtime User
Lovely your work is amazing, I'm sorry, do you mind me asking please?

I recently spoke about this php library , https://github.com/mevdschee/php-crud-api, here in the forum, which seems to be similar in functionality as your awesome product here. I just want to be sure though, for making a well informed decision, is there something that is of major difference between your version and this github one?

OP: https://www.b4x.com/android/forum/t...g-mysql-crud-rest-api-php-using-axios.142814/

Thank you in advance.
 

fernando1987

Active Member
Licensed User
Lovely your work is amazing, I'm sorry, do you mind me asking please?

I recently spoke about this php library , https://github.com/mevdschee/php-crud-api, here in the forum, which seems to be similar in functionality as your awesome product here. I just want to be sure though, for making a well informed decision, is there something that is of major difference between your version and this github one?

OP: https://www.b4x.com/android/forum/t...g-mysql-crud-rest-api-php-using-axios.142814/

Thank you in advance.
Well, after reading the documentation and reviewing the post, I can tell you that it is not the same code, but thanks, I will study that code, it can help me improve mine, something similar in the calls to the api, after that, that is all they would have of such an estimate. .. And thank you very much for asking.
 

Mashiane

Expert
Licensed User
Longtime User
Cool. The catch for me on the github poject (https://github.com/mevdschee/php-crud-api) was it able to connect to a variety of back-ends
  • PHP 7.0 or higher with PDO drivers enabled for one of these database systems:
  • MySQL 5.6 / MariaDB 10.0 or higher for spatial features in MySQL
  • PostgreSQL 9.1 or higher with PostGIS 2.0 or higher for spatial features
  • SQL Server 2012 or higher (2017 for Linux support)
  • SQLite 3.16 or higher (spatial features NOT supported)
As much as I have only tested it with MySQL only for now. The file size was also kinda large for me though it seemed to have some issues around security of the php which could add a great value.

Thanks for reverting back. All the best with your Magic Api.
 

fernando1987

Active Member
Licensed User
Cool. The catch for me on the github poject (https://github.com/mevdschee/php-crud-api) was it able to connect to a variety of back-ends
  • PHP 7.0 or higher with PDO drivers enabled for one of these database systems:
  • MySQL 5.6 / MariaDB 10.0 or higher for spatial features in MySQL
  • PostgreSQL 9.1 or higher with PostGIS 2.0 or higher for spatial features
  • SQL Server 2012 or higher (2017 for Linux support)
  • SQLite 3.16 or higher (spatial features NOT supported)
As much as I have only tested it with MySQL only for now. The file size was also kinda large for me though it seemed to have some issues around security of the php which could add a great value.

Thanks for reverting back. All the best with your Magic Api.
Thank you I wanted to make it as simple as possible so that anyone could implement it even without knowledge in php it took me some time and some errors but I got it. I also had the opportunity to test my Posman B4X with a connection code generator to carry out the queries and I loved the final result. Seriously thanks for your support and your questions
 

fernando1987

Active Member
Licensed User
All the source codes and libraries of the store until the last day of the month of February will be at a 30% discount with the following coupon:

STORECODE30​

 

imbault

Well-Known Member
Licensed User
Longtime User
transform any database into a rest api in just 5 minutes and without programming or knowing php

instucciones:
1. create a database on your web server

2. create your tables it is important that each table created has the id field

3. upload the files inside the zip file to your server in the folder you want this would be your base url.

4. Edit the config.php file inside the core folder with your database connection details and you are ready to use your database as an api.

Example:


Download:

Hello Fernando,

do you have some security features, like bearer etc...?

Thanks
 
Top