You are on page 1of 10

Network Programming

BTCS703
Application program interface (API)

An application program interface (API) is code that allows two software programs


to communicate with each other.

The API defines the correct way for a developer to write a program that requests services
from an operating system (OS) or other application. APIs are implemented by function
calls composed of verbs and nouns. The required syntax is described in the documentation of
the application being called.

How APIs work

APIs are made up of two related elements. The first is a specification that describes how
information is exchanged between programs, done in the form of a request for processing and
a return of the necessary data. The second is a software interface written to that specification
and published in some way for use.
The software that wants to access the features and capabilities of the API is said to call it, and
the software that creates the API is said to publish it.

Three basic types of APIs


APIs take three basic forms: local, web-like and program-like.

Local APIs are the original form, from which the name came. They offer OS
ormiddleware services to application programs. Microsoft's .NET APIs, the TAPI (Telephony
API) for voice applications, and database access APIs are examples of the local API form.

Web APIs are designed to represent widely used resources like HTML pages and are
accessed using a simple HTTP protocol.  Any web URL activates a web API.  Web APIs are
often called REST (representational state transfer) or RESTful because the publisher of REST
interfaces doesn't save any data internally between requests. As such, requests from many
users can be intermingled as they would be on the internet. 

Program APIs are based on remote procedure call (RPC) technology that makes a remote
program component appear to be local to the rest of the software. Service oriented
architecture (SOA) APIs, such as Microsoft's WS-series of APIs, are program APIs.

Google APIs
In one way or another, Google APIs support most modern sites online. From analytics, to the
advertising exchange, maps, to Google+ shares, chances are, most sites are using a Google
API. Currently, 57 APIs are available from Google, as well as a number of other developer
tools. Tutorials abound if you find an API of interest, and for more general inquiries,
developers should check out this basic project by Google on using APIs.
 Google APIs: An ever-changing list of 57 Google APIs.
 Google Analytics API: Measure user interactions with your site or app across multiple
devices.
 Youtube API: Choose from the data or players API to embed types of players or offer
Youtube search capabilities.
 AD Exchange Buyer API: Lets you manage your Ad Exchange Buyer Account
 AD Exchange Seller API: Enables you to manage your Ad Exchange Seller Account.
 Picasa Web Albums API: Allows websites and apps to integrate Picasa Web Albums
by creating albums, uploading or retrieving photos, and more.
 Blogger API: View and update blogger content, query for posts that match criteria.
 Google Fonts API: Use a variety of custom fonts from Google on most modern
browsers.
 Google Translate API: Detect and translate the language of text in your site with only
javascript.
 Google Geocoding API: Create interactive maps with Google Maps.

Yahoo APIs
Though not as numerous as Google’s APIs, Yahoo has a number of valuable APIs including
Flickr (below in the social media section), a Yahoo marketing API, and Yahoos RSS feeds.
Yahoo’s connected TV API is a unique starting point for creating smart tv apps for
advertising, content, and video.
 Yahoo APIs: Yahoo’s 7 APIs can be coupled with a variety of their other web tools
and development platforms.
 Yahoo Connected TV API: Enables users to write TV apps in Javascript to deliver
dynamic content.
 Yahoo RSS Feeds API: Enables users to pull up content from sites sharing new posts
on Yahoo RSS feeds.
 Yahoo APT API: Buy and Sell advertising on Yahoo through this API.
 Yahoo Search Marketing API: Allows access to Yahoo marketing data for managing
marketing campaigns.

Social Media
Social media APIs are used for a variety of reasons. The ability to log into a site using a
social media profile helps users quickly access content, and keep the number of separate
accounts and passwords they have to keep track of low. The ability to instantly share content
socially, can be a great boom to app or site engagement, and the ability to look at social
media data and key into your true audience is always valuable.

 Twitter API: Enables an app to interact with most of Twitter’s functions.


 Scoop.it API: Find data on scoop.it users, topics, and posts.
 Facebook APIs: For ads, games, payments, login, sharing stats, and user data.
 Linkedin API: Enables apps to connect to user accounts, data, connections,groups,
communications, and social streams.
 Google+ API: Enables apps to login to Google+ view connections, groups, posts, and
contact information.
 Pinterest API:Enables apps to view the most clicked-through or repinned Pins, view
related posts, and user profiles.
 Tumblr API: Create new ways to use Tumblr with access to content, likes, followers,
and drafts.
 Instagram API: Search photos by location, user, tags, view trending photos, and make
custom items.
 Flickr API: Search through user Flickr content, contacts, upload or replace photos.
 VKontakte API: Access and exchange information from Vkontakte’s servers
 Meetup API: Integrate Meetup groups and the corresponding data with larger apps or
websites.

Marketplaces
Marketplace APIs can be well utilized in mashups, as a way to automatically post your site’s
goods on other marketplaces, and as a way to direct users to related goods. 3Taps API is
particularly powerful, allowing access to 7 separate mostly marketplace APIs, and in the
process of adding more functionality at the moment.
 Foursquare API: Use the API to access Foursquare’s places database detailing users
and merchants.
 eBay API: Search eBay categories, post things for sale, display eBay listings on other
sites, and search bidder information.
 3Taps API: Allows access to Craigslist, apartments.com, Indeed, eBay Motors,
cars.com, Hemmings Motor News, and Backpage APIs.

Other APIs of Interest


From Census data to weather to posting videos, there are tons of interesting and valuable
APIs out there. Here are a few of our favorites.
 Census API: Access vast datasets from the census on demographics, population, and
economic data.
 SoundCloud API: Build apps that allow users to upload and share sound online.
 Klout API: This API gives you “social influence” scores for people based on their
social media profiles, followers, and activity.
 Tastekid API: This API allows you to integrate suggestions for music, movies, shows,
and books based on their suggestion database.
 Bit.ly API: Shorten URL’s, search and analyze links with this API.
 Weather Underground API A database of reliable forecast and weather data in 80
languages.
 YR.NO API: The largest weather database in the world. NOTE: Requires translation
from Norwegian.
 Wordpress API: A variety of ways to extend Wordpress through plugins.
 Vimeo API: Search for data on videos, groups, channels, albums, and activity
 Yelp API: Find geographically-oriented data, search by highest ratings, distance from
location.
 Dropbox API: Allows your app to sync files and data with Dropbox, giving you
access to the Dropboxes of over 300 million global users.
 Janrain API: Tools to recognize customers across platforms, offer single sign-on, and
social login.
 Amazon S3: Use Amazon storage to utilize your own API. Free tier includes 5GB
storage, 20,000 Ger Requests, and 2,000 Put requests.
 Europeana APIs: Build applications that utilize a wealth of cultural heritage objects in
the Europeana repository.

Mashups
Here’s some inspiration on what can happen when you couple the power of a few APIs.
Valuable mashups can be as simple as using a site’s API and redesigning the interface
through which users view the data.
Oftentimes mashups look at overlapping data from multiple APIs to pull out new
relationships.
 Trendsmap: Utilizes trending twitter hashtags with geospatial data, providing a live
map of trending tweets. For a membership fee, historical data, higher levels of zoom, and
analysis are available.
 Poligraft: Enables users to place links to articles or copied pieces of text to receive the
back story on political figures mentioned.
 Spell With Flickr: Takes a word or string of words as input and creates a “ransom
note” of different Flickr images for each character.
 Housing Maps: Is a mashup between Craigslist and Google Maps that provides an
interactive map of properties for rent or sale

DLL Dynamic Link Library


A DLL is a library that contains code and data that can be used by more than one program at
the same time. For example, in Windows operating systems, the Comdlg32 DLL performs
common dialog box related functions. Therefore, each program can use the functionality that
is contained in this DLL to implement anOpen dialog box. This helps promote code reuse
and efficient memory usage.

By using a DLL, a program can be modularized into separate components. For example, an
accounting program may be sold by module. Each module can be loaded into the main
program at run time if that module is installed. Because the modules are separate, the load
time of the program is faster, and a module is only loaded when that functionality is
requested.

Additionally, updates are easier to apply to each module without affecting other parts of the
program. For example, you may have a payroll program, and the tax rates change each year.
When these changes are isolated to a DLL, you can apply an update without needing to build
or install the whole program again.

The following list describes some of the files that are implemented as DLLs in Windows
operating systems: 

 ActiveX Controls (.ocx) files


An example of an ActiveX control is a calendar control that lets you select a date from a
calendar.
 Control Panel (.cpl) files
An example of a .cpl file is an item that is located in Control Panel. Each item is a specialized
DLL.
 Device driver (.drv) files
An example of a device driver is a printer driver that controls the printing to a printer.
DLL advantages

The following list describes some of the advantages that are provided when a program uses a
DLL: 

 Uses fewer resources


When multiple programs use the same library of functions, a DLL can reduce the duplication
of code that is loaded on the disk and in physical memory. This can greatly influence the
performance of not just the program that is running in the foreground, but also other
programs that are running on the Windows operating system.

 Promotes modular architecture


A DLL helps promote developing modular programs. This helps you develop large programs
that require multiple language versions or a program that requires modular architecture. An
example of a modular program is an accounting program that has many modules that can be
dynamically loaded at run time.

 Eases deployment and installation


When a function within a DLL needs an update or a fix, the deployment and installation of
the DLL does not require the program to be relinked with the DLL. Additionally, if multiple
programs use the same DLL, the multiple programs will all benefit from the update or the fix.
This issue may more frequently occur when you use a third-party DLL that is regularly
updated or fixed.

DLL dependencies

When a program or a DLL uses a DLL function in another DLL, a dependency is created.
Therefore, the program is no longer self-contained, and the program may experience
problems if the dependency is broken. For example, the program may not run if one of the
following actions occurs: 

 A dependent DLL is upgraded to a new version.

 A dependent DLL is fixed.

 A dependent DLL is overwritten with an earlier version.

 A dependent DLL is removed from the computer.

These actions are generally known as DLL conflicts. If backward compatibility is not
enforced, the program may not successfully run.

The following list describes the changes that have been introduced in Microsoft Windows
2000 and in later Windows operating systems to help minimize dependency issues: 

 Windows File Protection


In Windows File Protection, the operating system prevents system DLLs from being updated
or deleted by an unauthorized agent. Therefore, when a program installation tries to remove
or update a DLL that is defined as a system DLL, Windows File Protection will look for a
valid digital signature.

 Private DLLs

Private DLLs let you isolate a program from changes that are made to shared DLLs. Private
DLLs use version-specific information or an empty .local file to enforce the version of the
DLL that is used by the program. To use private DLLs, locate your DLLs in the program root
folder. Then, for new programs, add version-specific information to the DLL. For old
programs, use an empty .local file. Each method tells the operating system to use the private
DLLs that are located in the program root folder.

DLL issues
Manually Fixing DLL Errors
Troubleshoot & Diagnose DLL Errors
The first step to fixing DLL errors is to identify the source of the error message. Because
DLL’s are non-executable and require other programs to operate, the error begins with a
separate software entity. Examine the original error message and take note of the DLL file in
error, its file path, and the program that threw the error. With this information, you can start
troubleshooting the DLL error.
Troubleshooting Software
DLL’s are called upon by programs and services for various reasons. If the program that calls
the DLL is in error itself, it might cause a false DLL error. To troubleshoot this possibility,
re-install the software referenced in the error message.
Update Drivers
DLL errors can be caused by buggy, out-of-date device drivers. To troubleshoot this
possibility, update the drivers for all of the hardware devices installed in your computer.
Device drivers for OEM systems can be obtained from the system manufacturer’s website.
Scan for Malware
Some malware infections can masquerade as legitimate DLL’s and cause errors. Scanning for
malware is an important step to troubleshooting DLL errors. Use your preferred anti-virus
software to scan for malicious infections that could be causing DLL errors. If you do not have
anti-virus software, download this free solution here.
System Restore
If the DLL error can’t be fixed by working around it, you may try restoring your computer to
an earlier date when the DLL file was in working condition. To do this…
(Windows: All Versions)
1. Start the computer in Safe Mode. (Press F8 when booting the computer and select the
safe mode option)
2. Press the Windows key and the R key at the same time to open the Run prompt.
3. Type into the Run prompt: rstrui.exe 
4.

5. Press Enter. The Windows System Restore wizard will open in a new window.
6. Click Next to proceed.
7. The next step is to select the date you want to restore to. Check the box next to Show
more restore points to see older restore points. Select a restore point before the time when
the DLL error started and click Next.

8. Click Finish to confirm the selected restore point.


Log back into Windows normally. If the error persists you may try another restore point or
continue troubleshooting below.

Repair Missing/Damaged DLL Files


In most DLL error cases, the DLL file in question is simply missing or corrupted. The only
way to fix this problem is to replace DLL file. For most system DLL files, you may copy the
DLL from a different computer with an identical configuration. However, if this option is not
available to you, the files will have to be replaced from a Windows installation media. For
Windows XP, an installation disc of the same version of the installed operating system is
required to perform this repair. For Windows Vista, 7 and 8, a startup repair may be
attempted. Startup repair may be accessed from the Advanced Windows Boot Options menu
by pressing F8 when the computer is booting up and selecting Startup Repair as the boot
option.

JavaBean
A JavaBean is a Java class that should follow the following conventions:

o It should have a no-arg constructor.


o It should be Serializable.
o It should provide methods to set and get the values of the properties, known as getter
and setter methods.

Why use JavaBean?

According to Java white paper, it is a reusable software component. A bean encapsulates


many objects into one object so that we can access this object from multiple places.
Moreover, it provides easy maintenance.

Simple example of JavaBean class

1. //Employee.java  
2. package mypack;  
3. public class Employee implements java.io.Serializable{  
4. private int id;  
5. private String name;  
6. public Employee(){}  
7. public void setId(int id){this.id=id;}  
8. public int getId(){return id;}  
9. public void setName(String name){this.name=name;}  
10. public String getName(){return name;}  
11. }  

How to access the JavaBean class?

To access the JavaBean class, we should use getter and setter methods.

1. package mypack;  
2. public class Test{  
3. public static void main(String args[]){  
4. Employee e=new Employee();//object is created  
5. e.setName("Arjun");//setting value to the object  
6. System.out.println(e.getName());  
7. }}  
Note: There are two ways to provide values to the object. One way is by constructor and
second is by setter method.

JavaBean Properties

A JavaBean property is a named feature that can be accessed by the user of the object. The
feature can be of any Java data type, containing the classes that you define.

A JavaBean property may be read, write, read-only, or write-only. JavaBean features are
accessed through two methods in the JavaBean's implementation class:

1. getPropertyName ()

For example, if the property name is firstName, the method name would be getFirstName() to
read that property. This method is called the accessor.

2. setPropertyName ()

For example, if the property name is firstName, the method name would be setFirstName() to
write that property. This method is called the mutator.

Advantages of JavaBean

The following are the advantages of JavaBean:/p>

o The JavaBean properties and methods can be exposed to another application.


o It provides an easiness to reuse the software components.

Disadvantages of JavaBean

The following are the disadvantages of JavaBean:

o JavaBeans are mutable. So, it can't take advantages of immutable objects.


o Creating the setter and getter method for each property separately may lead to the
boilerplate code.

You might also like