L04L - An Introduction To Netcentric Development
L04L - An Introduction To Netcentric Development
NETCENTRIC
DEVELOPMENT
HTTP, REST API, Tools
COS216
AVINASH SINGH
DEPARTMENT OF COMPUTER SCIENCE
UNIVERSITY OF PRETORIA
IP CLASSES
Class E 240.0.0.0 to 254.255.255.254 Reserved for future use, or research and development purposes.
IP CLASSES
https://youtu.be/0dFNpNgiTAA
IP CLASSES
WHY 127.0.0.1?
• 127 is the last network number in a class A network with a subnet mask of
255.0.0.0.
• 127.0.0.1 is the first assignable address in the subnet.
• 127.0.0.0 cannot be used because that would be the wire number (network
address).
HYPERTEXT TRANSFER PROTOCOL
Application protocol
Hypertext Transfer
for transmitting
Protocol (HTTP)
hypermedia
• HTTP/0.9
• Created in 1991
• HTTP/1.0
• Created in 1993
• HTTP/1.1
• Created in 1997
• Still most widely used version
• HTTP/2.0
• Standardized in 2015
• HTTP/3
• Uses the QUIC protocol
HYPERTEXT TRANSFER PROTOCOL
HTTP/FTP/
POP/SMTP/IMAP
TCP/UDP
IP
HYPERTEXT TRANSFER PROTOCOL
• HTTP is stateless
• Stateless protocols do not save states/variables/memory between requests
Accept-Encoding List of acceptable encodings. See HTTP compression Accept-Encoding: gzip, deflate
List of acceptable human languages for response. See Content
Accept-Language Accept-Language: en-US
negotiation
An HTTP cookie previously sent by the server with Set-Cookie
Cookie Cookie: $Version=1; Skin=new;
(below)
Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348
The Media type of the body of the request (used with POST and Content-Type: application/x-www-form-
Content-Type
PUT requests) urlencoded
The date and time that the message was originated (in "HTTP-
Date Date: Tue, 15 Nov 1994 08:12:31 GMT
date" format as defined by RFC 7231 Date/Time Formats)
The domain name of the server (for virtual hosting), and the
TCP port number on which the server is listening. The port
Host Host: en.wikipedia.org
number may be omitted if the port is the standard port for the
service requested.
HTTP REQUEST EXAMPLE
HTTP RESPONSE HEADERS
INTERNET text/plain
text/html
Plain Text
HTML
MIME application/xml
application/json
XML
JSON
• Example:
• Request URL: http://moviesite.com/api?type=movie&title=avatar&year=2009
• Request Body: None
HTTP POST PARAMETERS
• Example:
• Request URL: http://moviesite.com/api
• Request Body: action=login&username=satoshi&password=Complex$1Pass
URLENCODE
• Examples:
• Twitter & Facebook: Retrieve your friend’s latest post/tweet
• Trakt.tv: Retrieve movie and TV information
• CoinMarketCap.com: Retrieve the latest crypto currency prices
REST APIS
https://www.youtube.com/watch?v=7YcW25PHnAA
• Request: https://api.coinmarketcap.com/v1/ticker/
• Response:
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
HTTP APIS – "rank": "1",
"price_usd": "8558.77",
COINMARKETCAP.COM "price_btc": "1.0",
"24h_volume_usd": "10752600000.0",
"market_cap_usd": "144242234626",
"available_supply": "16853150.0",
"total_supply": "16853150.0",
"max_supply": "21000000.0",
"percent_change_1h": "1.1",
"last_updated": "1518094763"
},
...
]
• Request: https://api.trakt.tv/movies/tron-legacy-2010
• Response:
{
"title": "TRON: Legacy",
"year": 2010,
"ids": {
"trakt": 343,
"slug": "tron-legacy-2010",
HTTP APIS –
"imdb": "tt1104001",
"tmdb": 20526
},
• Everything web-
related (HTML, JS,
CSS, PHP, MYSQL,
much more …)
ONLINE RESOURCES – PHP.NET
• More documentation
on PHP
ONLINE RESOURCES –
STACKOVERFLOW.COM
• Questions,
code snippets, and more
QUESTIONS?