Api Generator

DronaHQ now offers a super simple way to create an API just by uploading data, or even without any data. Creating an API sometimes takes a lot of time. While configuring all those routes and middlewares, we often loose time for other important tasks. Now you can focus on other tasks, and for the API part, API Generator comes to the rescue where you can generate both the Rest API or GraphQL API according to your need.

Process

  1. Input Data
  2. Preview & Modify Data
  3. Select API type and API name
  4. Generate API
  5. Integrating API with DronaHQ

Input Data

Choose input data for your API, it can be

  • CSV File: Upload your CSV file here (file size should not be more than 2 MB)
  • Raw JSON: Paste your JSON data here (nested json is also supported)
  • Auto generate data: This option allows generating dummy data, when the number of rows are specified (max 100 rows at a time).

Preview & Modify Data

An editable table (datagrid) appears once you press the “Next” button after selecting the data. This feature allows you to modify the data before generating the API. You can directly modify your data inside the table by:

  1. Renaming column name
  2. Reordering columns (Dragging columns to change the order in which they appear)
  3. Inserting or removing columns
  4. Inserting or removing rows
  5. Editing column type (Autofills the entire column with the selected column type)

Column naming conventions

  1. Must start with alphabets or underscore.
  2. Should be a combination of alphabets, numbers and underscore.
  3. Cannot end with _id

Note: This feature is not available for Raw JSON data input

Select API type and API name

Here you get the option to choose whether to create a REST API or a GraphQL API and also to name your API, by default the name is data.

Note: You can only create REST API for Raw JSON data input

Generate API

Lastly, press the “Generate API” button to create the API. Once the API is created, depending upon the API type selected, the system displays all the API endpoints that you can use.

REST API Endpoints

You can copy the curl request for any endpoint by clicking on the copy button situated to the right of each endpoint.

OpenAPI 3.0 Specs

In REST API, you can also download the OpenAPI 3.0 doc in json format by pressing the button “Download OpenAPI 3.0 Specs” as shown above. In case you forgot to download the OpenAPI doc on this screen or your doc is deleted/missing from your system you can follow the below mentioned steps to retrieve it.

  1. Consider your API endpoint is https://apigenerator.dronahq.com/api/vFCjyEuh/data
  2. Now remove the API name from the endpoint, in our case it is “data”, it will become something like this: https://apigenerator.dronahq.com/api/vFCjyEuh
  3. Navigate to this address from your browser and download the OpenAPI doc JSON.

GraphQL API Endpoints

In GraphQL API, there are two types of operations you can perform: Queries and Mutations . Queries are the GraphQL equivalent to GET calls in REST and Mutations represent the state-changing methods in REST (like DELETE, PUT, PATCH, etc). You can copy the query/mutation for any endpoint by clicking on the copy button situated to the right of each endpoint.



When you click on one of the GraphQL query/mutation, you will be redirected to GraphiQL tab with the query/mutation syntax loaded onto its query editor.

Note: Your sample API will be deleted if it has not been used in the last 30 days

Integrating API with DronaHQ

  1. Manually add REST API endpoint, follow this article.
  2. Bulk add all REST API endpoints using OpenAPI 3.0 specs JSON, follow this article.
  3. Add GraphQL Query/Mutation, follow this article.