Darshita Jain
4 min readJun 29, 2017

--

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 -Emergency Contacts, present in my data model.

Data present in the emergency contacts table

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

Output of the insert query-

A new row has been added to the table

2. Update query is used to modify the data present in the table.

Output of the above update query is-

3. Delete Query is used to remove rows of data present in the table

Output of the above delete query -

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

Output of the select query-

After executing the above queries the final table is -

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.

--

--

Darshita Jain

Researcher at Tata Research Development and Design Centre| MTech CSE | IIT Gandhinagar