3.2 HASURA DATA API AND POSTMAN COLLECTION

In this blog post, I will provide you an insight into the instant JSON data API provided by Hasura, and how to query your database using postman by making use of these data API. Before starting, please do read about my application’s data model using the below link -

After adding tables to Postgres via the Hasura console, the data service is able to provide API for performing CRUD (Create, Read, Update, Delete) queries across all the defined tables.

Data management section in the Hasura Console

Using the External endpoint, in this case http://data.c100.hasura.me/ , the API can be used and tested using Postman.

Note: Before making queries to the database, you need to set the permissions for different user so that they can make appropriate queries. For that, select the required table from the console then go to Modify tables, Relationships and Permissions and set the required permissions.

First make some settings in the Header and Body section of the postman app as shown-

  • In the Body section select raw and JSON(application/JSON)
  • Set the request type to be POST and enter the External Endpoint for making use of Data API.
  • In the Header section add the key- Authorization, with value- Bearer <admin token>

You can find your admin token from the Hasura Console-

Now, I will illustrate some CRUD queries using postman on the table -pass_mgr , present in my data model.

  1. Insert query is used to add data into the table

2. Select query is used to display the data present in the table

RESOURCES THAT CAN BE USED-

  1. Screen cast illustrating Hasura Instant Data APIs

2. Hasura Docs

Next I will write about using Hasura Auth API and Postman.