What is an API?

Discussion in 'Programming' started by moe374, Dec 2, 2008.

  1. #1
    In Java, what exactly is an API? I have searched/read using google, and from what i understand it is "a set of classes and methods" and used specific documentation/commenting guidelines. But I still dont understand exactly what that means in terms of me creating an API. What makes my program different from an API besides for the documentation?
     
    moe374, Dec 2, 2008 IP
  2. pharmboy

    pharmboy Member

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    An API is basically an interface to a library of routines. It's a way to expose the functionality of one's code to others. Does your program serve some generically useful purpose that others would want to plug into (to reuse your code)? If not, then there's no reason to produce an API for it.
     
    pharmboy, Dec 2, 2008 IP
  3. daringtakers

    daringtakers Well-Known Member

    Messages:
    808
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Read the Wiki definition of API
     
    daringtakers, Dec 2, 2008 IP
  4. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #4
    API is just the interface for outsiders to use your code.
     
    harrisunderwork, Dec 3, 2008 IP
  5. firmaterra

    firmaterra Peon

    Messages:
    756
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Think of it like this. If you were coding a program for a car you might have a class called 'car'. You might also have various types of cars pre-coded - honda, toyato, porche. And the methods for the car - drive, accellerate, reverse, brake, crash.

    You might then make an API to allow external users use those classes and methods. That is your API! You might also provide some documentation like JAVA does with seperate explanations for constructors for the car, classes and methods belonging to the Car.

    A basic example I know, but the thinking is much the same.
     
    firmaterra, Dec 3, 2008 IP