Plugin API vs Class Library API - api

There is a lot of stuff here on what an API is, but I can't find what I need on the distinction between plugin APIs and class library APIs. I don't get it anyway.
In the book, Documenting APIs, I read: The key difference between a plugin API and a class library API lies in the which party supplies the implementation for the exposed API.
Plugin API: The publisher creates an application and exposes a plugin API; the 3rd > party developer implements the API. The 3rd party developer plugin extends the functionality of the publisher's application.
Class library API: The publisher creates the API and implements it. The end-user uses the class library via its API to write an application. With a class library, the publisher implements a library of functionality that exposes an API.
I think I understand the plugin. I'm not clear on the class library API. Is it like a printer manufacturer creating a driver based on an O/S class library so that their printer works with that O/S?
If so, could you explain more about the differences in the APIs themselves? Are they both still a set of exposed methods? And how does the publisher implement its own API?
References
Documenting APIs: http://www.amazon.com/documenting-APIs-writing-developer-documentation/dp/0963002104
What is the difference between a Java API and a library?
Difference between framework vs Library vs IDE vs API vs SDK vs Toolkits?
API vs Toolkit vs Framework vs Library

They are both software interfaces. This means that they both look similar, typically a Java archive (JAR) containing a package (or multiple packages) with interfaces, classes, exceptions, etc.
I can understand why you found the explanation from the book confusing. As far as the API itself is concerned, the Java implementation is provided in both cases.
The major difference is in how this Java code is used. In the case of Plugin API (I like to call it Service Provider Interface, or SPI) you are primarily expected to add your own functionality by implementing the provided Java interfaces and/or extending the provided classes. On the other hand, you are only expected to call a Library API (I like to call it simply API), you are rarely expected to implement interfaces or extend classes.
Because of how they are used, there are many subtle differences between how you design an SPI and how you design an API. While I don't have a post dedicated to comparing SPI and API, when I discuss the various aspects of API design, I usually point out these differences:
http://theamiableapi.com/

Related

What do I have here? API or Web Service

I have a project for Master's Degree: design and implementation of web services for an elearning platform.
Now, I know that there are two main architectures for web services: SOAP, and REST
Now, I wanted to use REST architecture, so normally I would have something called "RESTful web services", so I started development with Django and Django Rest Framework
Now, this is the part where I get confused, Is this an API or Web Services
If it is an API, then how can I develop RESTful Web Services?
If it is both, please explain more if you could.
I'm very confused about this, and each time I try to understand, I get more confused, Please can someone clarify this to me?
An application programming interface (API) allows you to interact with a component, system, or resource. It's a very broad concept. To understand it, the emphasis should be placed on the word interface:
In computing, an interface is a shared boundary across which two or more separate components of a computer system exchange information. The exchange can be between software, computer hardware, peripheral devices, humans, and combinations of these.
When you need something from a component or you want it to do something for you, you don't just go in it and do it yourself, you "ask it" for that something or for that action by interfacing with it. The interface of the component says what it can do for you or what you can invoke from the component.
In regards to web services, you have to understand that a web service is in fact an API, because it's an interface with some component (in this case whatever is behind the web service itself: it can be a database, an application, a system, etc).
Like I said, an API is a very broad term. When you say web service, you are adding some restrictions to that term. For example, a web service is invoked over the network. Not all APIs are like this. Some API's can be exposed as libraries, or frameworks that you call directly from your code as methods or functions. So all web services are APIs, but not all APIs are web services.
If you want to build a web service, you can implement it with REST or with SOAP. There is a difference between the two (REST is an architectural style, while SOAP is a protocol), but as concepts they work the same: they provide an interface with which to interact over the network, i.e. an API. But since you are using Django, thus Python, I suggest you go the REST way, not SOAP (support for SOAP in Python isn't all that great).

Does exist a universal tool to describe different APIs (REST, WebSocket, gRPC, custom framework)?

My project uses different protocols to communicate with other services:
REST API
WebSocket (STOMP)
gRPC
own framework build over gRPC.
I need a tool, or a bunch of tools, which allow me to generate documentation for the APIs. In the best scenario, it's a maven plugin that generates a report with all APIs.
We use Swagger to describe the REST API. It has poor export options and needs a lot of annotations in the code, but describes the API well and offer the test machine.
Alternatively, Spring RestDocs (AsciiDoctor) could be used for the REST API describing. It offers a better format for reporting, but we prefer Swagger.
That's all I found for the REST API. But I didn't find anything for describing WebSocket API, gRPC and the custom framework.
I will be very grateful for any help and ideas to solve the problem.

Platform-agnostic web framework in kotlin

I am looking for framework, that has some basic framework tools like routing, templates and possibly some other tools useful for web (but also other types of apps), that are not dependent on platform (ex. nodejs/java). I don't see reason why this has to be 100% platform specific. If there's routing and generic request/response object, there can be implementation for example both for node express or for example java servlets with correct mapping and wrappers. Has anyone tried to do that yet? I couldn't find anything.
You may want to take a look at Ktor.

what does Swagger server stub mean?

What does the term Server Stub mean in the context of the Swagger ecosystem? How is it used?
From a swagger tutorial:
With SwaggerHub, you can easily generate a server stub (an API implementation stub) for Node.js, ASP.NET, JAX-RS, and other servers
and frameworks. The server stub is a good starting point for
implementing your API – you can run and test it locally, implement the
business logic for your API, and then deploy it to your server.
https://app.swaggerhub.com/help/apis/generating-code/server-stub
and a stub is:
method stub or simply stub in software development is a piece of code used to stand in for some other programming functionality. A stub may simulate the behavior of existing code (such as a procedure on a remote machine, such methods are often called mocks) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in porting, distributed computing as well as general software development and testing.
https://en.wikipedia.org/wiki/Method_stub
Stub the API means : create à mock to serve examples described in swagger file.
This mock can be formatted in specific languages/ framework
Server stubbing can be quite powerful depending on the backend platform and framework you plan to use for your API.
For example, you may choose Apache (common in Linux environments) or ASP.NET (common for IIS). The server "stubs" being generated will typically be a deployable library to that specific platform. What you typically get is:
Routing to your business logic. The framework will handle the HTTP specification, but actually mapping from a "controller" to your service layer is being handled by the code generator, based on your API specification.
Serialization and Deserialization of your models (applies to strongly-typed languages like Java/C#).
AuthN/AuthZ may be handled, to some degree, based on the framework's support for your API's chosen auth scheme.
tl;dr: A server stub is intended to be a ready-to-deploy application that routes HTTP requests to your actual business logic on the backend.
From my experience and peers, I found stub to be a mock function or a placeholder function where you can fill in the proper implementation later.

Does api work like bytcode to provide multi-platform functionality

I've recently come across the term api and from what I have known api is a interface that connects/integrates between two programs and it can run on any platform.
And again from java we know that it turns it's source code into bytecodes and this bytecode can run on any platforms since it is platform independent.
So my question is does api work/run just like as a bytecode to provide multi-platform functionality
And if not is there any similarities between them or thier process? If please anyone could explain it to me it would be a great help. Thanks in advance.
API does not work like bytecode
Actually, API and Bytecodes are a completely different thing
For Bytecode,
let's try to understand it in java. java compiler compiles a java program then produce bytecode. Then the bytecode is interpreted by java interpreter in different machines and generate different executable files as the requirement of different machines and os.
this is how java maintains it's multi-platform property
Now, API,
API stands for Application Programming Interface. An API is a software intermediary that allows two applications to talk to each other. In other words, an API is the messenger that delivers your request to the provider that you’re requesting it from and then delivers the response back to you.
there are many types of API's out there
but I think you are referring to Web API and it's multi-platform functionality and how it works.
A Web API is an application programming interface for either a web server or a web browser
A Web API works as server-client architecture.
client request to server through HTTP protocol, server responds to client through HTTP protocol
actually whole api service is provided through HTTP protocol, and this api service can provide to any device using HTTP protocol
this has nothing to do with bytecode