An API is a set of programming code that enables data transmission between one software product and another. When people speak of “an API”, they sometimes generalize and actually mean “a publicly available web-based API that returns data, likely in JSON or XML”. An API is not the database or even the server; it is the code that governs the access point(s) for the server.
Private APIs: These application software interfaces are designed for improving solutions and services within an organization. In-house developers or contractors may use these APIs to integrate a company’s IT systems or applications, build new systems, or build customer-facing apps leveraging existing systems. Even if apps are publicly available, the interface itself remains available only for those working directly with the API publisher. This private strategy allows a company to fully control the API usage.
Partner APIs: Partner APIs are openly promoted, but shared with business partners who have signed an agreement with the publisher. The common use case for partner APIs is software integration between two parties. A company grants partners access to data or capability benefits from extra revenue streams. At the same time, it can monitor how the exposed digital assets are used, ensure that third-party solutions using their APIs provide a decent user experience, and maintain a corporate identity in their apps.
Public APIs: Also known as developer-facing or external, these APIs are available for any third-party developers. A public API program allows for increasing brand awareness and receiving an additional source of income when properly executed.
APIs can be classified according to the systems for which they are designed.
Database APIs: Database APIs enable communication between an application and a database management system. Developers work with databases by writing queries to access data, change tables, etc. The Drupal 7 Database API, for example, allows users to write unified queries for different databases, both proprietary and open source (Oracle, MongoDB, PostgreSQL, MySQL, CouchDB, and MSSQL).
Operating systems APIs: This group of APIs defines how applications use the resources and services of operating systems. Every OS has its set of APIs, for instance, Windows API or Linux API (kernel–user space API and kernel internal API).
Remote APIs: Remote APIs define standards of interaction for applications running on different machines. In other words, one software product accesses resources located outside the device that requests them, which explains the name. Since two remotely located applications are connected over a communications network, particularly the internet, most remote APIs are written based on web standards. Java Database Connectivity API and Java Remote Method Invocation API are two examples of remote application programming interfaces.
Web APIs: This API class is the most common. Web APIs provide machine-readable data and functionality transfer between web-based systems which represent client-server architecture. These APIs mainly deliver requests from web applications and responses from servers using Hypertext Transfer Protocol (HTTP).
This is the API type that we will be looking at today. An easy way to send web API requests is by using Postman. We will be querying NeoWs (Near Earth Object Web Service) from NASA. This is an open API and no authorization is needed to access it. First, let’s look at different HTTP methods.
GET: GET is used to request data from a specified resource.
POST: POST is used to send data to a server to create/update a resource.
PUT: PUT is used to send data to a server to create/update a resource.
HEAD: HEAD is almost identical to GET, but without the response body.
DELETE: The DELETE method deletes the specified resource.
PATCH: Unlike PUT, PATCH applies a partial update to the resource.
OPTIONS: The OPTIONS method describes the communication options for the target resource.
The two most common HTTP methods are: GET and POST.
After installing Postman, you can add a collection from the ‘Create Collection’ button as seen here or by pressing the + next to Collections.
The next step is adding a request, which can be done by pressing the ‘meatballs’ menu. You can name this request whatever you prefer. We will call it NEO.
Now, we paste the URL for the API in ‘Enter request URL’. Make sure that your request type is a GET request.
The ‘Params’ tab is filled in automatically due to the query in the URL. API Query parameters can be defined as the optional key-value pairs that appear after the question mark in the URL. Basically, they are extensions of the URL that are utilized to help determine specific content or action based on the data being delivered. Query parameters are appended to the end of the URL, using a ‘?’. The question mark sign is used to separate path and query parameters. The start_date and end_date can now be specified for a period you want to look at. We are looking at NEOs on 2021-05-20.
This is what the output will look like. Usually, these outputs are in JSON format, working with key-value pairs.
Stay up to date with the latest AI news, strategies, and insights sent straight to your inbox!