API Flashcards
What is an API?
API (Application Programming Interface) is a software intermediary that enables two applications to communicate with each other.
What are main differences between API and Web Service?
- All Web services are APIs but not all APIs are Web services.
- Web services might not contain all the specifications and cannot perform all the tasks that APIs would perform.
- A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication whereas API may be exposed to in multiple ways.
- A Web service always needs a network to operate while APIs don’t need a network for operation.
What are some architectural styles for creating a Web API?
- HTTP for client-server communication
- XML/JSON as formatting language
- Simple URI as the address for the services
- Stateless communication
Who can use a Web API?
Web API can be consumed by any clients which support HTTP verbs such as GET, PUT, DELETE, POST. Since Web API services do not require configuration, they can be easily used by any client.
What is API Testing?
is a kind of software testing which determines if the developed APIs meet expectations regarding the functionality, reliability, performance, and security of the application.
What are principles of an API test design?
- Setup: Create objects, start services, initialize data, etc
- Execution: Steps to apply API or the scenario, including logging
- Verification: Oracles to evaluate the result of the execution
- Reporting: Pass, failed or blocked
- Clean up: Pre-test state
What is REST?
REST (Representational State Transfer) is an architectural style for developing web services which exploit the ubiquity of HTTP protocol and uses HTTP method to define actions. It revolves around resource where every component being a resource that can be accessed through a shared interface using standard HTTP methods.
What is a “Resource” in REST?
REST architecture treats any content as a resource, which can be either text files, HTML pages, images, videos or dynamic business information.
REST Server gives access to resources and modifies them, where each resource is identified by URIs/ global IDs.
What are some key characteristics of REST?
- REST is stateless, therefore the SERVER has no status (or session data)
With a well-applied REST API, the server could be restarted between two calls, since all data is transferred to the server - Web service uses POST method primarily to perform operations, while REST uses GET for accessing resources.
What are the core components of an HTTP request?
- An action showing HTTP methods like GET, PUT, POST, DELETE.
- Uniform Resource Identifier (URI), which is the identifier for the resource on the server.
- HTTP Version, which indicates HTTP version, for example-HTTP v1.1.
- Request Header, which carries metadata (as key-value pairs) for the HTTP Request message. Metadata could be a client (or browser) type, format supported by the client, format of a message body format, cache settings, and so on.
- Request Body, which indicates the message content or resource representation
Is there any difference between PUT and POST operations?
PUT operation is idempotent, so you can cache the response while the responses to POST operation are not cacheable, and if you retry the request N times, you will end up having N resources with N different URIs created on server.
What is URI? What is the main purpose of REST-based web services ?
URI stands for Uniform Resource Identifier. It is a string of characters designed for unambiguous identification of resources and extensibility via the URI scheme.
The purpose of a URI is to locate a resource(s) on the server hosting of the web service.