Search

APIs

Updated: May 6

Application Program Interface (API) permits the interaction between two systems.


  1. Endpoints https://sv443.net/jokeapi/v2/

  2. Paths https://sv443.net/jokeapi/v2/categories

  3. Parameters https://sv443.net/jokeapi/v2/joke/Programming,Miscellaneous?blacklistFlags=religious&type=twopart

  4. Authentication https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=439d4b804bc8187953eb36d2a8c26a02


Parameters start after the question ? mark and each are separated by ampersand &


Example of API Payload in JSON format:

{ "formatVersion": 2, "category": "Miscellaneous", "type": "single", "joke": "A horse walks into a bar...", "flags": { "nsfw": true, "religious": false, "political": true, "racist": false, "sexist": false } }

An API endpoint is basically a fancy word for a URL of a server or service.


APIs operate through ‘requests’ and ‘responses.’ And when an API requests to access data from a web application or server, a response is always sent back. The location where the API sends a request and where the response emanates is what is known as an endpoint.  Reputedly, the endpoint is the most crucial part of the API documentation since it’s what the developer will implement to make their requests.


An API refers to a set of protocols and tools that allow interaction between two different applications. In simple terms, it is a technique that enables third-party vendors to write programs that can easily interface with each other. On the other hand, an endpoint is the place of interaction between applications. API refers to the whole set of protocols that allows communication between two systems while an endpoint is a URL that enables the API to gain access to resources on a server.


use of APIs to aid in the transfer of critical data, transactions, and processes.


Endpoints help to depict the exact location of the resources to be accessed by API.


JSON - Javascript Object Notation


Pretty

{
 "coord": {
 "lon": -0.13,
 "lat": 51.51
    },
 "weather": [
        {
 "id": 801,
 "main": "Clouds",
 "description": "few clouds",
 "icon": "02d"
        }
    ],
 "base": "stations",
 "main": {
 "temp": 17.33,
 "feels_like": 11.87,
 "temp_min": 15.56,
 "temp_max": 20,
 "pressure": 1020,
 "humidity": 55
    },
 "visibility": 10000,
 "wind": {
 "speed": 7.2,
 "deg": 90
    },
 "clouds": {
 "all": 20
    },
 "dt": 1588603542,
 "sys": {
 "type": 1,
 "id": 1414,
 "country": "GB",
 "sunrise": 1588566366,
 "sunset": 1588620501
    },
 "timezone": 3600,
 "id": 2643743,
 "name": "London",
 "cod": 200
}

Raw

{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":17.33,"feels_like":11.87,"temp_min":15.56,"temp_max":20,"pressure":1020,"humidity":55},"visibility":10000,"wind":{"speed":7.2,"deg":90},"clouds":{"all":20},"dt":1588603542,"sys":{"type":1,"id":1414,"country":"GB","sunrise":1588566366,"sunset":1588620501},"timezone":3600,"id":2643743,"name":"London","cod":200}

Another option to JSON is XML - extensible markup language.


Big picture of using an API


Client -> Your Server -> API -> Third Party Server


Client makes GET request to our server.


Our server makes GET Request to 3rd party server to fetch data and Receives Response back as a JSON via API.


Requests made with Parameters, Path, key value pairs.


Response from API with data.


Send data from our server with a response to client.


Ctrl+K+C, you'll comment out the section of code. Ctrl+K+U will uncomment the code

Recent Posts

See All

Socket Programming in Python

Sockets and the socket API are used to send messages across a network. The network can be a logical, local network to the computer, or one that’s physically connected to an external network like the i

Financial Machine Learning

"The essential tool of econometrics is multivariate linear regression, an 18th century technology that was already mastered by Gauss before 1794...It is hard to believe that something as complex as 21

©2020 by Arturo Devesa.