Skip to main content
Version: v2.x

Quickstart RESTified Endpoints

RESTified endpoints allow you to quickly and easily create REST endpoints without writing custom code. This quickstart will walk you through the process of creating a REST endpoint from a table.

To see an alternative method of creating a REST endpoint from an query in the GraphiQL IDE, check out the Create RESTified endpoints page.

DOCS E-COMMERCE SAMPLE APP

This quickstart/recipe is dependent upon the docs e-commerce sample app. If you haven't already deployed the sample app, you can do so with one click below. If you've already deployed the sample app, simply use your existing project.

Deploy to Hasura Cloud

Step 1: Navigate to the products table.

Navigate to Data > default > public > products and click the "Create REST Endpoints" button.

Create RESTified Endpoint

Step 2: Choose operations

After clicking on the "Create REST endpoints" button, you will see a modal list of all REST operations (READ, READ ALL, CREATE, UPDATE, DELETE) available on the table. Select READ and CREATE for this demo. Click the "Create" button.

Create RESTified Endpoint

Step 3: View all REST endpoints

You will be able to see the newly created REST endpoints listed in the API > REST tab.

Create RESTified Endpoint

Step 4: Test the REST endpoint

Click on the products_by_pk title to get to the details page for that RESTified endpoint. In the "Request Variables" section for id enter the value 7992fdfa-65b5-11ed-8612-6a8b11ef7372, the UUID for one of the products already in the products table of the docs sample app. Click "Run Request".

Create RESTified Endpoint

You will see the result returned next to the query.

You can test the other insert_products_one endpoint that we created in the same way by providing a new product object as the request variable.

You can also use your favourite REST client to test the endpoint. For example, using curl:

curl --location --request GET 'https://<your-hasura-project>.hasura.app/api/rest/products/7992fdfa-65b5-11ed-8612-6a8b11ef7372' \
--header 'Content-Type: application/json' \
--header 'x-hasura-admin-secret: <your-admin-secret>'

Recap

What just happened? Well, you just created two REST endpoints for reading a single product and inserting a product, super fast, and without writing a single line of code 🎉

This saves you significant time and effort, as you easily enable REST endpoints on your tables or convert any query or mutation into a REST endpoint with just a few clicks.

By using RESTified endpoints, you can take advantage of the benefits of both REST and GraphQL, making your Hasura project even more versatile and powerful. For more details, check out the configuration page.