Making calls to a public API
If there's a public API server that has it's source code licensed with AGPL, and if I make an app that uses these public endpoints in some part of it, ... is this considered as "derivative work" thus oblige me to license my code with AGPL too?
No. A derivative work is only possible if you've copied at least some part of the original work, or if you've made a new work based on an existing work. E.g. if you wrote a similar program with similar functionality while having access to the original program, then your new program could possibly (but not necessarily) be considered a derivative work.
In the situation you describe (making requests to a server), you are not copying anything that could be considered a portion of the program itself. You are merely running the program.
If that public API server is offering a service to you using (A)GPL code, then that server operator is the one that needs to comply with the software licenses, because she is the one that copied the code onto her server in order to offer the services to you.
Generally speaking, if you are only running a program, and not copying it or making a derivative work from it, no permission is generally required according to copyright laws. The GPL (and thus, the AGPL as well), even go so far as to explicitly affirm that you are indeed allowed to run a GPL-covered program, even if you do not accept the underlying license:
- Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program.
Does this allow circumventing the AGPL?
Let's say there's an open source library licensed with AGPL, and if I were to create a thin API wrapper around it, ..., can I make a closed sourced app that does RESTful calls to a server that has this new API deployed, thus effectively bypassing the restrictions of AGPL for the library?
If the AGPL program does not offer a REST API, and you decide to add one to it and then offer that program on a server where users can interact with it, then the AGPL would require that you contribute the source code of your version (i.e. the one with the REST API implemented) to anyone who can access the service through a network.
[If] you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your
version supports such interaction) an opportunity to receive the
Corresponding Source of your version ...
In this sense, you are not circumventing anything. You made changes to the AGPL program, so you must disclose your source to that program.
As for your second program that calls your REST service, the AGPL does not make any requirement on that program for the same reason as mentioned above (calling a REST service is not a form of copying the program).
Does this circumvent the purpose of AGPL? I don't believe so. The purpose of AGPL is to prevent you from circumventing your obligation of contributing your improvements to the program itself. For example, suppose you have an idea for improving the GNU C Compiler (which is GPL licensed), so you download the GCC source and make your improvements. According to the GPL, the mere fact that you've modified GPL code is not enough to require you to release your source code changes. Only if you actually distribute your custom GCC program are you required to release your source code (or a Written Offer to provide the source code). Not wanting to do this, you decide to instead install your custom GCC program onto your own server, and then only let users interact with it over a network. Since GCC is GPL licensed (and not AGPL licensed), this would be OK according to the license, although it would probably be a shame, since the authors of GCC probably intended for you to eventually disclose your source code changes when you finally release your software. It's just that technically you never "released" your software in this case.
The intention of the AGPL is to clarify this sitation -- if you take an AGPL-licensed program, and make changes to it in some way, and then you let users interact with your version over a network, the AGPL says that that bascically counts as releasing your version, so you need to in turn release your source code to your version.
See also: Why the Affero GPL