DEV Community

Cover image for Top ways to call an API
Vegan Tech
Vegan Tech

Posted on

Top ways to call an API

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 and the API Tester (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

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

Image description

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

From there, click on GET.

Image description

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

Image description

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

Image description

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

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

Image description

Then input the API URL and click send.

Image description

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

Image description

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

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

Image description

Then input the API URL and click send.

Image description

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

Image description

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

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

Image description

Then input the API URL and click send.

Image description

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

Image description

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

Image description

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

Image description

Image description

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.

Top comments (0)