APIs and client server - paper 2 Flashcards
(20 cards)
what are APIs
- a set of protocols that governs how two applications should interact with one another.
- An API sets out the format of requests and responses between a client and a server and enables one application
to make use of the services of another.
limits of HTTP communication
The client must send a request to the server to receive data.
If too much time passes without activity after a socket connection is established,
The server closes (drops) the connection to save resources.
When this happens, the server often sends an error message (like a timeout).
Bandwidth overhead: HTTP headers add extra data, increasing bandwidth usage.
Latency: Each request-response cycle can cause delays, especially over slow networks.
Text-based: Less efficient for binary data compared to some other protocols.
web CRUD applications
NAME → HTTP request method → SQL command
Create → POST → INSERT
Retrieve → GET → SELECT
Update → PUT → UPDATE
Delete → DELETE → DELETE
what is REST
Representational State Transfer is a software architectural style for designing networked applications
examples of APIs
JSON - similar to python dictionary
XML - similar format to html files
advantages of JSON
- more compact so requires less storage, so quicker to transmit and process
- easier to read, write, and maintain
- data clearly defined as objects
disadvantages of JSON
- only works with a limited range of data types
Less secure: Can be vulnerable to injection if not properly handled.
Text-based: Larger in size compared to binary formats like Protocol Buffers.
Parsing errors: Small syntax mistakes (like missing commas) can break the whole file.
No support for comments: Can’t add explanations directly in the data.
advantages of XML
Human-readable and machine-readable: Easy to understand and process by both people and programs.
Platform-independent: Works across different systems and technologies.
Flexible structure: Can represent complex data types
Supports custom tags: Allows users to define their own tags for specific needs.
Widely supported: Many tools and languages have built-in XML support.
Facilitates data sharing: Great for exchanging data between different applications.
disadvantages of XML
expensive use of tags makes it hard to follow
Slower processing: More complex to parse than formats like JSON.
Higher bandwidth usage: Large file size means more data to transfer.
Harder to write manually: Tedious and error-prone without tools.
Not ideal for data storage: Inefficient for large datasets or frequent read/writes.
describe what thin- client computing is
- processing is carried out on a server
- Minimal local processing: Most of the computing is done on a central server, not the client device.
Relies on network connection: Needs a stable connection to access applications and data.
Lightweight hardware: Thin clients can be low-power devices (e.g., terminals, Chromebooks).
Centralised management: Easier to update, secure, and maintain systems from the server.
Common in businesses: Used in environments like schools, offices, and call centres.
how does the client - server model work
- a client will send a request message to a server
- which should respond with the data requested or a suitable message otherwise.
example of a client - server model
Client (e.g. browser) sends a request for a web page.
The server receives the request and finds the needed page/data.
The server sends back a response with the web page content.
The browser displays (renders) the web page on the user’s screen.
This is how many websites work using the client-server model.
examples of server types
File server
Email server
FTP server
Proxy server
DHCP server
Print server
Database server
example of an API
WebSocket is a modern application layer
protocol that facilitates a persistent bi-directional communication channel between the client and the
server over a single line. This is known as full-duplex communication.
Persistent connection until the communication is terminated;
Reduced header information, increasing data transfer speed; and reducing load on server
Connecting a database to a browser with HTTP request methods
User interacts with browser: e.g., submits a form or clicks a button.
Browser sends HTTP request: Using methods like:
GET – to fetch data (e.g., view products).
POST – to send new data (e.g., submit a form).
PUT/PATCH – to update existing data.
DELETE – to remove data.
Server receives request: Backend processes the request using code (e.g., Python, Node.js, PHP).
Server interacts with database: Sends SQL queries to retrieve, insert, update, or delete data.
Server sends HTTP response: Returns data (usually in JSON) or confirmation to the browser.
Browser updates UI: Based on the server’s response (e.g., shows new content or success message)
advantages of thin client
- Easy to set up, maintain and add
terminals to a network with little installation required locally - Software and updates can be installed
on the server and automatically distributed to each client terminal - More secure since data is all kept centrally in one place
disadvantages of thin client
- Reliant on the server, so if the server
goes down, the terminals lose functionality - Requires a very powerful, and reliable
server which is expensive - Server demand and bandwidth increased
- Maintaining network connections for
portable devices consumes more battery power than local data processing
advantages of thick client
- Robust and reliable, providing greater
up-time - Can operate without a continuous
connection to the server - Generally better for running more
powerful software applications
disadvantages of thick client
- More expensive, higher specification
client computers required - Installation of software required on
each terminal separately and network administration time is increased - Integrity issues with distributed data
how does thin client computing work
- Client terminals load operating system from server at start up;
- Applications installed on server and accessed remotely by terminals;
- Client (dumb) terminals act as interfaces only;
- All processing is done by the server