Aq1's avatar
Level 1

Will somebody PLEASE explain API?

I know many of you will be like 'Oh c'mon you don't know about apis and you are working in laravel'. Well my fellows, yes I have a loooot of confusion about this API thing.

You see, all this time I thought that API is used when we want to add third party functionality in our project or we can create an api of our own project so others can utilize our project's functionality (Please correct me if I am wrong.)

Kindly note that I am at a very beginner/basic level in laravel app development and I have developed some basic applications. And I have not used any third party APIs (Facebook api etc.) or haven't created any API myself. Although I have used some packages in my projects like google2FA..

Can we consider Packages as an API?

Well the other day, someone I know (who is a Senior Laravel Developer) asked me about my project and I told him that I am working on a human resource management project then he asked me how many apis have you created in this project and then I was like "I have NO IDEA what you are saying.." . Anyway I told him that I haven't created any API yet.

So my question is, you guys have any idea what he was talking about? what apis? I know should have asked him this but tbh I was too embarrassed to ask.

Thanks for bearing with me.

0 likes
7 replies
mironmg's avatar

First of all, you shouldn't be embarrassed of anything you do. In this field everyone's constantly learning. I think of API like a "thing" that helps applications communicate with each other. Usually people associate these with some json/xml data involved but that doesn't have to be 100% true. You can think of packages as APIs if they help implementing a 3rd party service for example. Take Stripe, Paypal, etc... The easiest definition I can think of is a tool that helps transferring data between 2 applications.

2 likes
jlrdw's avatar

Api is very broad term.

To get a good idea go to the FedEx site and they have API interfaces.

Places like adopt a pet will have API interfaces also.

It's basically a Communications interface to another system.

To either present data or retrieve data from your system.

2 likes
Sergiu17's avatar

I'll try to explain what I call API from a package.

Let's say that the following class is from a Package

class Image
{
    private $height;
    
    private $width;

    public function move();

    public function delete();

    private function optimize();
}

Now when I use this class (Package) in my project

$image = new Image();
$image-> // here I have access to two methods: move and delete
// and this is what I call API
1 like
Snapey's avatar
Snapey
Best Answer
Level 122

API can be any agreed interface between two things

So, the methods you expose in a package is your packages API - the ways others can interact with the package

Third parties can have APIs that you want to access to get from or set data on their service - again, the API determines the ways you can interact with the service

Your own application can have an API - the ways that your clients can interact with your application

Think of it like a border. Whenever something passes from one area of responsibility to another you need an API to agree how the two parties will interact with each other.

3 likes
illuminati's avatar

API is a middle thing. Like a waiter between customer and chef.If you want something to eat that the chef make, you must ask the waiter to tell the chef to make something for you. You not have the permission to tell the chef directly. The waiter tell the chef and take the food you order to him for you. This is the example. I hope this fact can help you. This is the work what api do.

2 likes

Please or to participate in this conversation.