Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:30:35+00:00 2026-06-12T02:30:35+00:00

I’d like to automatically generate a web API from a database. I can easily

  • 0

I’d like to automatically generate a web API from a database. I can easily query the database with SQL, but obviously this won’t do for a public API. I can also write the server-side code manually, but this will take a very long time, since the database is fairly large. Also, writing it manually would be a very mechanical and repetitive task, so I don’t see why a program can’t do it for me.

For example, let’s say I have a table in my database called “Announcements”. I’m looking for a way to (given that database table), automatically generate the server-side code that will allow someone to create new announcements, requiring the correct fields. Done manually, this could look like a PHP file called “create_announcement.php”, which requires all the fields that exist in the database, like the announcement title, body, and author. Of course, this could also be done in a cleaner way by following some design model (like REST), but this is meant as an example.

Other things I’m considering are:

  • Some form of authentication. For example, if the user would like to delete an announcement, he/she should be required to “log in” to do so. I’m not sure how this works here.
  • Some way to add logic. If I can generate an API to access the database through HTTP (as I tried to describe above), the API will not be aware of certain specificities. Let’s say the announcement resource should include a date that must be after today. I need a way to express that in the code.
  • It would be ideal if the solution could follow some design model to make it easier to access from different clients.

So what kind of tools should I look into? What is the general approach people take when confronted with this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:30:37+00:00Added an answer on June 12, 2026 at 2:30 am

    The comments above have listed out some great existing software, you’ve really got to figure out whether or not you want to reinvent this concept.

    If you write this yourself you can still save a lot of time vs writing each page & action individually, but the validation you’re talking about is probably going to eat up all of your time if you don’t already have that functionality built into these models, if they exist.

    Something simple could take in a table name, action name, id number from the URL and spit out basic stuff.

    <?
    $allowed_tables = array('posts','comments','people');
    
    $table = $_GET['table'];
    $page = (int) $_GET['page'];
    
    $per_page = 100;
    $offset = ($page - 1) * $per_page;
    
    if (!$table || !in_array($table, $allowed_tables)) {
        die('Invalid table.');
    }
    
    
    $rs = mysql_query("SELECT * FROM `$table` ORDER BY `id` DESC LIMIT $per_page, $offset");
    $data = array();
    
    if ($rs && mysql_num_rows($rs)) {
        while ($row = mysql_fetch_array($rs,MYSQL_ASSOC)) {
            $data[] = $row;
        }
    }
    
    print json_decode($data);
    ?>
    

    You could definitely make some serious progress in a couple of hours, adding in fields to specifically show or hide, you could even deal with the validation on a simple basis (required fields would be simple) for now just to get it rolling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a view passing on information from a database: def serve_article(request, id): served_article
I would like to count the length of a string with PHP. The string
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.