DEV Community

Cover image for 🦄How to deploy your own API? - Part 1
Luciano Jung
Luciano Jung

Posted on • Edited on

🦄How to deploy your own API? - Part 1

Tired of having a static frontend with no way to share your data between applications? Why not build your own free API backend!

In this blogpost series I want to give you a basic understanding of APIs, show you what information you need to use an API and what alternatives to APIs are available. In the next part I want to demonstrate how you can create a simple API using Spring Boot and Heroku. The last part of the series will show you how to use Flutter to access your API and process the data at runtime.
Follow me to not miss any following posts.

Content

iconfinder_485_book_pen_food_education_4212930

What is an API?

API (long for Application Programming Interface) is an interface that allows data to be exchanged between multiple applications. It allows systems to communicate with each other and collect data that other systems have generated or collected themselves.

So basically, APIs are back-end applications hosted on servers with public (usually encrypted) interfaces. If you have permission to access them, you can usually communicate with them over an Internet connection and receive data for further processing. It is important to know that you're not receive just the whole database behind the API, when you access it, rather than already processed data without gaining access to sensitive information, the application didn't want you to see.

iconfinder_481_university_bank_campus_court_4212926

What are the benefits of APIs?

In a nutshell, external APIs can increase the productivity of your systems and analytical results with less cost and time consumption by serving massive data. While APIs you create improve connectivity and collaboration with other software systems to get better and more reliable applications.
If you are a beginner, it's good to build your own API so that you understand the structure of an API and how to deal with them.

iconfinder_496_bulb_energy_idea_solution_4212938

What do you need to know about an API to use it?

If you want to get started with an API, you need to know the following:

1. What base URL do I need to call to access an API?

The base URL tells you how to test the API and where to access it in production.
-> For example: https://api.myService.com/
Modern APIs also use versioning so that an application doesn't have to choose between crashing or updating when the API is updated.
-> For example: https://api.myService.com/version_2/

2. What encryption method does the API use?

If you can access the API without an access key: Great, skip this point!
If not, find out what authentication method the API uses and what security schemes you can use to access it. Many APIs allow you to access with more than one security scheme.
Most APIs use TLS encryption or WS Security as the authentication method.
Common security schemes include access tokens, id-key authentications, or OpenID Connect.
Sometimes you just need to create an account to get an access token.

3. What data format will I receive in response?

To process the response, you first need to know what data format you will receive as a response. Common data types are:

  • json
  • xml
  • yaml
  • csv

Most of them have the key-value principle: they have a static key (e.g. name) and a dynamic value (e.g. dev-reader):
name: dev-reader
So it is important for you to understand the object structure. If you do, you can easily retrieve the value every time you access the API by simply knowing the key.
Sometimes you have plain text as the data format. I don't know what's going on with developers issuing plain text to users, but most of the time they have a structure that you have to figure out.

iconfinder_516_pedestal_first__first_place_education_4212898

BONUS: What are alternatives to APIs?

While there is hype around APIs and I recommend every full-stack developer look into it, there are of course alternatives to using APIs:

1. Manual download

When a company publishes a document and you want the information in it, you simply download it. However, it's easy to see that this method is quite heavy when dealing with large data sets and you have to manually update the data every time.

2. website crawling

If a company don't want to create an API you can get your data by crawling through their websites programmatically. However, without the consent of the website owner, it is not suitable to simply crawl his website. If crawling happens regularly, the website operator can take action against it and protect certain crawlers or entire areas against crawling.

3. Restricted database access

If you want to cooperate with a company but they didn't provide an API you can ask them for a restricted database access. While this is a better solution than the previous ones when it comes to rapidly changing data sets, it does require some effort to set up.

4. Don't append on external data

It's easy to say but some applications don't need external data. And because of that they don't need APIs. It's not advisable for every system to use APIs.
If you still need external data for your application APIs are recommended in most cases!

iconfinder_478_cloud_arrow_book_notebook_4212923

Comments

What are your experiences with API Services?
How do you want to use an API Service?
What do you think is the 🦄-Icon in the Header for?
Let me know in the comments below!

Alt Text
With the knowledge you gained in this post i want to build and deploy a simple api in the next parts of this series.

Follow me to not miss any following posts.
See my latest Projects on Github or at Lucianojung.de


You may also like:

Sources

The Creator of the Icons used in this article is Flatart downloaded from Iconfinder.
The Images used in this article are published on Flexiple.

Top comments (0)