Create your own API site

Last updated on
12 November 2024

Introduction

These instructions are for creating a site similar to Drupal API using the API Module.

How to create an API site

Quick setup

The module has a demo folder containing a readme file and a script that you can run in isolation and the script will do everything for you. See the readme file inside the demo folder for a one-line command.

Step by step

You can also run the steps one by one to better understand how the module works:

Setup the site

  1. Begin with a Drupal site that is compatible with a Drupal 10+ version of the API module.
  2. Add the API project with a command similar to this. Check the API module page for available versions.
    composer require drupal/api
  3. Add batch UI module. This is optional.
    composer require drupal/queue_ui
  4. Install the API module and the Queue UI module.

Setup the module and projects

Step-by-step version

Now, get the code to parse and display. The default location the API module will look for is sites/default/files/api_git_repositories. In this example, Drupal core is the project and the current working directory in the Drupal root. Adjust the command as needed for your project.

git clone --branch 11.x http://git.drupal.org/project/drupal.git ./sites/default/files/api_git_repositories/drupal

Once the project files are in place

  1. Go to admin/config/development/api/project and add a new project.
  2. Go to admin/config/development/api/branch and add a new branch.
  3. Process the queue to index the branch, using either cron admin/config/system/cron or the Queue UI
    1. Got to admin/config/system/queue-ui,
      1. Select 'Batch process' action.
      2. Select 'Parse Queue Worker'
      3. Save changes
  4. Go to your new api documentation at path: api. The content should resemble the content at Drupal API.

Quick version

All the above setup steps can also be done via the QuickWizard UI (and drush command) where you only need to put the "https" URL of the repo and the branches to parse (optional, defaults to all), and the form (or command) will do everything for you automatically.

Help improve this page

Page status: No known problems

You can: