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 -
Data modelling is often the first step in database design in which the analysis of data objects and their relationship…medium.com
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.
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.
- 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-
- Screen cast illustrating Hasura Instant Data APIs
2. Hasura Docs
Let's import some data into our tables. Since, Postgres is the underlying database, we need to import data into…docs.hasura.io
Next I will write about using Hasura Auth API and Postman.