Tutorial: Building a GET API with WayScript
Published: 2020-05-05 15:31:56

---
title: "Tutorial: Building a GET API with WayScript"
canonical_url: https://wayscript.com/learn/building-get-api-wayscript
---
##Introduction
WayScript makes it really easy to make a fully fleshed out APIs in minutes. Today we'll be be discussing how to make a GET API.

##Prerequisites
In order to make the API, we'll utilize an HTTP Trigger, a SQL Module, a Python Module, and an HTTP Response. There are no prerequisites but some content you might find helpful:
[Working with HTTP](https://docs.wayscript.com/library/modules/http-response)
[Working with Python](https://docs.wayscript.com/library/modules/python)
[Working with SQL](https://docs.wayscript.com/library/modules/sql)

##Building the GET API
With WayScript, you can set up a workflow really quickly.
![New Script](https://cdn.wayscript.com/blog_img/85/startAPP.PNG)

You can create a workflow by clicking the `+ New Script` Button in the top right corner of the website.

In this Script, to make a workflow he using the HTTP Trigger module, which will make a request to our database any time we hit a valid endpoint. Modules are sort of like building blocks, to help form the foundation of our application. After adding the HTTP Trigger Module to the workflow, click on the module and go to the window in the left to add endpoints and query paramters for your API.

![add endpoint](https://cdn.wayscript.com/blog_img/85/addendpoint.PNG)

After adding the query parameters we can get going with connecting to our SQL database and using the query parameters from our HTTP Trigger.

First, click the SQL Module. WayScript allows you to sink up with a MySQL, PostgresSQL, or SQL Server DB and is adding new ones all the time.

![MySQL](https://cdn.wayscript.com/blog_img/85/sqlSetUp.PNG)

After you put in your DB info you. You can query it and alter the qurey so that you can use one of the parameters from your HTTP Trigger.

![Query parameter](https://cdn.wayscript.com/blog_img/85/useQueryParameterInSql.PNG)

Now we can query the database to get the entry that we want! Make sure to set up indexes at the columns you would like to use.

Next you need to take the information from your Database response and turn it into a JSON response with the Python Module.

![Python code](https://cdn.wayscript.com/blog_img/85/PythonModuleCode.PNG)

Click on the Python Module and create a JSON response and put it in your dictionary as resp so you can reference it later.

WayScript type checks your dictionary variables so they make it really easy to know if you formatted your response correctly.

![http response](https://cdn.wayscript.com/blog_img/85/httpResponse.PNG)

After you add your response to your HTTP Response module and turn on the HTTP Trigger you're good to go!

##Result
If you call or go to the endpoint at the supplied query parameters you can see your response!  

![valid json](https://cdn.wayscript.com/blog_img/85/validJSON.PNG)

If you would like to see this example app check out [this script with GET and POST requests](https://wayscript.com/user/erik_toor/9FL_bX4B), it is public on the WayScript market place. Also feel free to check out other scripts on the [WayScript Market Place](https://wayscript.com/marketplace).

Here's a great video of Erik Toor building this Script. 

{% youtube HZxo52iuPMg %}