Top ways to call an API
Tags: api, testing
Published: 2022-11-01 16:19:05

If you want to build your million-dollar startup or a hobby project, first, you need a server that manages your data and logic. To build a server, you need to know how a server works.

A server usually contains multiple APIs. APIs are like a road that is used to send and receive data. Each API can be called in many different ways. Today I'll show you some of those ways.

First of all, we need an API server. You can create your own server using your favorite programming language, or you can use services like https://webhook.site, which lets you test APIs without needing to create a server. 

Now we're going to demonstrate the ways to call APIs using the [Postman](https://www.postman.com) and the [API Tester](https://apitester.org) (supports Android & iOS).

**1. GET**

The GET is the most popular way to call an API. It can be called from a browser directly. However, as the name describes, it is usually used to fetch data from the server.

To call an API using the GET method, in Postman, select GET(1), input the API URL(2), and hit send(3).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1ql9yrvexivnlykmzov.png)

The webhook page shows that the API got called using the GET method. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sn2fbwdv1itwxuqmmmho.png)

Let's do the same using the API Tester APP (which supports Android & iOS ). First, open the app and click on the Create new request button. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjotzj8qrxffbna4bw1z.png)

From there, click on GET. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3klgn97z13ugq6h54xi.png)

Then input the webhook URL and click the send button at the top-right corner.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frrixdz7q01rqf76ue82.png)

You'll see there's a new call to the API with the GET method.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6urzk017uxgc7jaxjbbx.png)

**2. POST**

The POST method is usually used to send data to the server from the app. For example, to call an API using the POST method, in Postman, select POST, input the API URL, and hit send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfkks8shhkz012x833vy.png)

Or, if you prefer your smartphone, in the API Tester app, create a new request using the POST option.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yoick68oee2u7nas709p.png)

Then input the API URL and click send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuhuqn918hg1jlx4juho.png)

In the webhook page, you'll see it got called using the POST method.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oxk4cj82o8hcnupcc0dx.png)

**3. PUT**

The PUT method is usually used to send data to the server from the app but to change or update specific data. For example, to call an API with the PUT method, in Postman, select PUT, input the API URL, and hit send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgjib6wcsfguugxedaaq.png)

Or, with the API Tester app, create a new request using the PUT option.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aewtn2e25banvfklppm0.png)

Then input the API URL and click send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyy446xezpf3vtx7qczq.png)

In the webhook page, you'll see it got called using the PUT method. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7hd27miq03cj83fdj5s.png)

**4. DELETE**

The DELETE method is usually used to delete one or multiple data. To call an API with the DELETE method, in Postman, select DELETE, input the API URL, and hit send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzvdm0nu78b4ibtntjhq.png)

In the API Tester app, create a new request using the DELETE option.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojhmccjx5bm5r27dozvm.png)

Then input the API URL and click send.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmfmk3a9njdljnm1djng.png)

In the webhook page, you'll see it got called using the DELETE method. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vu05o1awiaqoh59r5z9.png)

These are not just all, and there are other methods like PATCH, COPY, HEAD, and so on.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3snsq6rieeio26yh6sp.png)

All these methods can be found in the API Tester app. In addition, the API Tester app has even more methods to call APIs out of the box. Here are some screenshots of the supported methods in the API Tester app.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18i6eizjz9wpuaqw0hbh.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqk6lrvmm2hl8o3whta3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/099n9hie48isktdg596i.png)

You can also call an API with a custom method of your own. Maybe your name or your company name, or your app name.

If you want to test different APIs from your phone, give the API Tester app a try. It's free and supports Android & iOS. 

Now that you have created a server with multiple APIs, you want to protect it from hackers. Learn the top ways you can protect your server from hackers in my previous [post.](https://dev.to/vegan_tech/top-ways-to-secure-apis-from-hackers-4jl7)