3.2 Hasura Data API + Postman collection
Now we will learn about 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 our application’s data model using the below link -
Backend revolves areound Database design in which the analysis of data objects and their relationship with other data…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
- 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 we move on to, Auth APIs.
Till then, Happy Learning! :)