Hasura Internship 2017(Task 3.2): Hasura Data API + Postman collection

Aamir
3 min readAug 7, 2017

--

Link to data modeling done in part 3.1:

https://medium.com/@aamircnd2/hasura-internship-2017-task-3-1-data-modeling-for-image-manager-app-64d62405d4e8

API(Application Programming Interface) is something of a tunnel between two programs which allows the transfer of data between them and the data is allowed to flow through it follows a certain set of rules or customs you may say.

Definition of an API: it is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components.

The Hasura Data API provides an interface with the Database(Postgres is this case) in which we created our Data Model, hence allowing any external app to communicate with the data present in it via following the proper protocols.

The data service is exposed at data.<project-name>.hasura-app.io. All data API queries are done at data.<project-name>.hasura-app.io/v1/query.

Any request made to these end points can read data off any table with has permissions to anonymous role assigned to it.Tables with permissions for user role can be accessed by using sending a valid authorization token via the header.

More info about the hasura data api:
https://docs.hasura.io/0.6/getting-started/4-data-query.html

Postman

Postman is a desktop tool for prototyping APIs. It can be used to make requests to Hasura API.
Download Postman app from https://www.getpostman.com/apps

For a Post request the body type should be set to
raw — JSON(application/json).

Some CRUD(create read update delete) request send to Hasura Data Api through Postman:-

  1. Insert new Image:

Sending a post request to Image table with the appropriate data in the appropriate format through postman

2. Selecting image details

In order to select user info along with image info a join can be used to query the data in one shot. Alternatively a view can be created with read permission set to true for all users.This makes querying of data easier to understand and debug later.

Creating Dashboard view

3.Selecting tags assigned to an image

4.Updating image info

5.Deleting an image

--

--