Hasura Data API + Postman collection
Before I indulge into explaining how the Hasura Data API works (which is actually my agenda today) I would like to explain the keystones in the path to get there. The first thing that comes up is WHAT IS AN API.
The formal definition of API is “a set of functions and procedures that allow the creation of applications which access the features or data of an operating system, application, or other service.”
APIs enable organisations to extract and share data in an accessible manner. Today, APIs are the foundation of many applications and technologies that we use — whether it is booking a ticket on IRCTC or sharing a The Hindu article to Facebook.
Now let me talk a bit about the best tool I’ve come across to test such API and it’s none other than our very own “made in India” POSTMAN.
Postman is a Google Chrome app for interacting with HTTP APIs. It presents you with a friendly GUI for constructing requests and reading responses.
It serves as a platform to make your API development faster & easier, from building API requests through testing, documentation and sharing.
Now I’m going to perform some CRUD (Create Read Update Delete) operations on my database using postman on to the Hasura Data API, but before that you might would like to visit my blog on data modelling.
For quick reference I’ve recorded a simple video explaining the basic concepts of what an API is, what functions do hasura Data and Auth APi perform with some illustrations. Here is the link.
Now let’s get started:-
In this screenshot you can see a table named expense has been created. I’ve created this table using the console of Hasura itself.
After having created the table I need to make a login request for the Auth API so that I can further manipulate the data.
Here you can see that I’m making a request at the Auth API external endpoint with username and password as the arguments.
In the result you can see that I’ve received a auth_token which would be required for validating my session.
Before inserting you need to make sure that “user” has the permission to insert. For doing so:-
Now you can insert values to the table by making a request the external endpoint of the Data API with the auth_token of the given user.
To read the table we to make the following request to the external data API endpoint.
Here I’ve updated the E_amt value from 1500 to 1000 where the E_id value is 2.
Here I’ve delete the data where E_id was equal to 2.
In this given link you can find the postman collection for the CRUD operations that I’ve performed.
Thank you :)
Index of contents in this web-app development series
- Idea of the app — Hisab-Kitab: Save to Earn
- Prototype of the app
- Setting up the development environment
- Learning Git
- Setting up local development setup
- Data model of the app
- Hasura Data API + Postman collection
- Hasura Auth API + Postman collection
- App Screen 1 (UI + Backend integration)
- App Screen 2 (UI + Backend integration)
- App Screen 3 (UI + Backend integration)
- User feedback and Testing
- Final app link