What is an API?
|
An API is a way for two or more computer programs or components to communicate with each other, enabling efficient data exchange and functionality sharing.
APIs allow for selective data retrieval from large, dynamic datasets, eliminating the need to download entire datasets for accessing small segments of data, thereby saving time and computational resources.
Both library APIs and web APIs share a fundamental principle of abstracting complexity, allowing developers to leverage pre-defined functions or data over the internet
|
Web APIs
|
Web APIs enable client-server interactions over the internet through a structured exchange of requests and responses, allowing for seamless data retrieval and submission.
The Hypertext Transfer Protocol (HTTP) is crucial for Web API operations, outlining how messages are formatted and transmitted, ensuring consistent communication across different platforms.
In HTTP, the communication involves requests initiated by clients (with methods like GET, POST) and responses from servers, each containing headers and potentially a body with the relevant data.
HTTPS adds a layer of encryption to HTTP, enhancing security by protecting data in transit, making it essential for sensitive transactions.
|
Data on the Web
|
|
Creating URL Queries
|
|
API Queries in Shell
|
You can request and process data from APIs using Unix shell tools
JSON or XML results can be parsed to plain text, to be consumed by standard Unix shell tools
|
API queries in python
|
|
Using LLMs for APIs
|
An API is a way for two or more computer programs or components to communicate with each other.
HTTP is the protocol originally designed for requesting and receiving Web pages, but now also used as the basis for a variety of APIs. HTTPS is the encrypted version of HTTP.
Every page on the world wide web is identified with a URL or Uniform Resource Locator.
A request is how you tell a server what you want to see. A response will either give you what you asked for, or tell you why the server can’t do that. Both requests and responses have a header, and optionally a body.
We can make requests and receive responses, as well as see their headers, using curl .
|