What is an API

Can someone please explain what is an API in terms of the software application and OS.

Though there are many articles avilable on the web, but yet can someone make it simple ( elaborate is more than welcome) to understand ( I am not from a CS background).

Though I have a basic idea I am interested to know in detail about what an API is , how it functions, and gets integrated with the OS and all about the calls and response calls and how they actually work. And what kind of tasks can an API ask the OS to do.

Guys can any CS guy be kind enough to answer this.

Replies

  • Manish Goyal
    Manish Goyal
    An application-programming interface (API) is a set of programming instructions
    A software company releases its API to the public so that other software developers can
    design products that are powered by its service.
    For example, Amazon.com released its API so that Web site developers could more easily
    access Amazon's product information. Using the Amazon API, a third party Web site can post direct links to Amazon products with updated prices and
    an option to "buy now."
    When you buy movie tickets online and enter your credit card information, the movie ticket Web site uses an API to send your credit card information to a remote application that verifies whether your information is correct. Once payment is confirmed, the remote application sends a response back
    to the movie ticket Web site saying it's OK to issue the tickets.
    I hope you have now a brief idea of api..
  • Rohan_sK
    Rohan_sK
    Thanks for your quick rpely goyal420, but I had already read this excerpt on the "HOWSTUFFWORKS" website.

    So I expected something different from an exact copy of what I had alreay read somewhere and something in your own words so that it can be much simpler and even better and lucid.

    Anyways thanks for responding so quickly.

    Anyone else Please help me out.
  • Gurjeet Singh
    Gurjeet Singh
    API is a set of programming instructions to like to help to the programmer or any other third party,like suppose we are the developer ,so java has provided us the jdk-doc.which contains the documentation,API..and so on.taking the example of java if the developer wants to execute some code but have the doubt about using the proper class or interface which he/she wants to implements ..so with the help of API ...we can get the classes which we want to use or method provided in that class or import packages.we can say is like a directory of records of all the functionality.
  • Mahesh Dahale
    Mahesh Dahale
    Rohan_sK
    Can someone please explain what is an API in terms of the software application and OS.

    Though there are many articles avilable on the web, but yet can someone make it simple ( elaborate is more than welcome) to understand ( I am not from a CS background).

    Though I have a basic idea I am interested to know in detail about what an API is , how it functions, and gets integrated with the OS and all about the calls and response calls and how they actually work. And what kind of tasks can an API ask the OS to do.

    Guys can any CS guy be kind enough to answer this.
    API.JPG (image)

    - basically consists of a variety of functions or procedures that an application program can call upon, as well as data structures, constants, and various definitions needed to describe system resources.
    - Applications programs use the API by including calls to routines in a program library
    - For example, this simple function puts a message box on the screen:
    MessageBox (0, “Program Initialization Failed!”,
    “Error!”, MB_ICONEXCLAMATION | MB_OK | MB_
    SYSTEMMODAL);
    - API for a major operating system such as Windows contains hundreds of functions, data structures,and definitions.
    - In order to simplify learning to access the necessary functions and to promote the writing of readable code, compiler developers such as microsoft and Borland have devised frameworks of C++ classes that package related functions together.

    API.JPG (image)

    [​IMG]
  • gaurav.bhorkar
    gaurav.bhorkar
    Is the API similar to standard library (for eg. in C)?
  • Rohan_sK
    Rohan_sK
    Dear Gaurav, the API functions are stored in one of the DLL's in the system 32 directory of Windows.
  • gaurav.bhorkar
    gaurav.bhorkar
    Rohan_sK
    Dear Gaurav, the API functions are stored in one of the DLL's in the system 32 directory of Windows.
    Ok. Now I get it. The API functions get called when we run the programs.
    So, the API code is not included in our program when we compile it. In C, the standard library functions' code we call, is included in our code when we compile.

    Am I right?
  • sookie
    sookie
    As far as I know what is an API[Application Programming Interface - assuming discussion was about this API only.] - As the full form says a programmed interface to the application. Now question comes what is this interface? If I just look at its literal meaning "An interface is an interconnection between two things" , here our things is application. So an interface helps in connecting two parts of an application. Now next thing is word "Programmed". So when I make my interface using some programming language then it is called as "Programmed interface" or an "interface" that helps me in programming my application. Now what exactly we program in these interfaces. Simple, we do nothing, just put some declarations of methods whose implementation is decided later by the person using it depending on his/her use.

    For e.g. I created some interface named Bounceable with a method declared as bounce(). Now a Ball and a Tire both of them can have this behaviour of bounce(). So if one application or a part I am using Ball type of class or object then I can use that already existing Bounceable interface and if in other application I am using Tire class then there also I can also use that Bounceable interface.

    Well, above was just an example [ not so good] in which I created my own interface but API are already created interfaces by some big organizations and they simply sell them and people like us who don't know creating them or who are enough lazy to do rework simply use them for getting our work done.

    API basically consists of declarations of methods and variables that implementing application uses according to their needs. In this way they provide a way of communicating from one application[implementing one] to the other application[interface providing application].

    PS: Feel free to point out if any wrong concepts or mistakes are there. Thanks !
  • gaurav.bhorkar
    gaurav.bhorkar
    Thanks sookie, for the valuable information.
  • Manish Goyal
    Manish Goyal
    Sookie...very nice information ...
    You clear my concept of interface in java..I usually wonder why these are required...
    I think these are quite useful if some one just want to have brief idea of program ..not full implementation of the code...
    and I think ...
    When some updates are available in internet for antivirus then these interface play an important role ....
    Am i right????????????
  • Kaustubh Katdare
    Kaustubh Katdare
    @Goyal: May I request you to stick to English in your posts?
  • Manish Goyal
    Manish Goyal
    @big_k sorry biggie ..for my mistake..actually this is my way of conveying thanks...any how i will follow rules of ce...hope i will not commit any such mistake
  • Rohan_sK
    Rohan_sK
    Hey Sookie,
    Thanks a lot for answering the question and giving some great insight.

    This was the type of response I had expected, with quite an analogical example, it helps relating things.

    @ Gaurav : I am really sorry, I simply missed my own thread ( it did get down the list ) and couldnt respond to you

    Ok. Now I get it. The API functions get called when we run the programs.
    So, the API code is not included in our program when we compile it. In C, the standard library functions' code we call, is included in our code when we compile.

    Am I right?
    Yes the API is a bit different from the C library, in the sense that in normal programs we make a call to the function. And the API are as I said previously is provided by the OS and stored in the DLL's of the system 32 . They are accessed by the program from these DLL's.

    Anyone else please feel free to add to this.
  • Maelstrom
    Maelstrom
    Hmmm... I read something about API in Let Us C. What follows may be fully or partially true or may be not true at all. But I would like to share with you what I understood about APIs (though I have never used them).

    Apparently, there were no APIs in DOS. So, in DOS if we had to interact with the hardware on the computer, we had to communicate with it directly. For example, if we had to print a document, then we would have to send the bitstream to the printer etc etc (I don't know what you're supposed to do to actually print a document, I'm just giving an example). Obviously, the problem with this method is that it is not general-purpose. If the printer was changed, then the whole program would have to be rewritten for the other printer.

    APIs came into existence with the advent of Windows. As their name suggests, they are interfaces. Carrying on with our example, the API is an interface which effectively says, "Just give me the document, I'll handle the printing." So, instead of doing everything inside the program, we just call the API and it handles the rest of the work. The improvement is immediately obvious - if the printer was changed, only the implementation of the API would need to change (and this will be provided by the printer manufacturer, we don't have to write it!), not our program. So we don't need to care what printer the computer is using, we're using the API.

    It's like driving a car. You don't have to know how a car actually accelerates, but you know that if you press the accelerator, it will go ahead. So the accelerator is the API. If you're driving a Maruti, it uses a spark to ignite the fuel, if you're driving a bus, it uses pressure to ignite the diesel, but you don't have to care about this while driving.

You are reading an archived discussion.

Related Posts

i am sanjiv and pursuing be in 3rd year in ec branch . i have to do training in either vlsi design , chip designing or embeded system , but...
Hello, I am working on a project. And part of it concerns the switching regulator. I am using the MC34063 from OnSemiconductors. I plan to use it as a step...
For constructing a small scale wind turbine which can be used on roof top of houses which is the best material for constructing the turbine or blades keeping in mind...
Guys, I've got a circuit for this device from "www.redcircuits.com/Page9.htm" , but there is problem... i.e., there's a buzzer which is to be sound when mercury switch is 'ON',(through walking)......
ok so like i im not sure where to post this if you can point me in the right direction please do so so i need to know the best...