I am making a piece of software and I plan to have it interact with the Discord API, which I know is nonfree because it expressly prohibits freedom 1 (the freedom to look at and modify the source code). If I release my software as free and open source under the GNU GPL v 3.0, is it still free? Or can I just not use the API?
Discord claims rights over two things here, the SDK (copying and use thereof) and their API (use and implementation thereof). The question of the SDK is pretty simple: it's a piece of software, and it's well-established that you can require end-users to agree to arbitrary terms when they take copies of your software, and expect them to be honoured.
The question of the API is much more interesting. Historically, ideas could not be copyrighted, only the expression of those ideas. So if Discord publishes the API, then although you can't make copies of the published API without permission, you can read and implement it de novo in your own code, and you haven't done anything that requires permission. This in turn means that Discord can't make you agree to their terms in order to implement it. Since their terms require you to restrict users of your code from certain kinds of use, and modification thereof, your software would be non-free. If you were to publish it under, say, GPLv3, you would be purporting to give your users rights that aren't yours to give, just as if you made unlawful copies of MS Office and resold them to end-users.
The idea that APIs couldn't be copyrighted was upended in the US by Google v. Oracle America, where two lower US courts found that they couldn't be, and the US Court of Appeal for the Federal Circuit twice reversed the decision. The cases were appealed to the US Supreme Court, who agreed to hear the matter following the second reversal. This they were scheduled to do on 2020 03 24, but the COVID crisis intervened, and the hearing has been rescheduled for the court's 2020-2021 term, when the Supreme Court is expected to rule on the specific question of the copyrightability of APIs.
There is, naturally, great interest in the outcome; many tech companies have filed amicus briefs, the great majority arguing against such copyrightability. The judgement will not, of course, have authority outside the US, but judges tend to keep an eye on what their colleagues are doing around the world, and the case cannot fail to have a global impact. The Supreme Court is, in turn, likely to have half an eye pointing towards the EU, where the Computer Programs Directive states in s11 of the preamble that
ideas and principles which underlie any element of a program, including those which underlie its interfaces, are not protected by copyright under this Directive
As I see it, if you're in a jurisdiction that holds that APIs aren't copyrightable, then because Discord have chosen to publish their API on github, you would be free to implement it without having to agree to their terms, and thus could do so in free software. If you're in a jurisdiction that holds that they are, then because of the terms on which the API is made available, it would be impossible for free software to implement the API.
As you can check the discord API on https://github.com/discord/discord-api-docs
It is an open API and you will be able to use this API in your application, but each API that is provided by a developer is bound by the legal terms set by the developer themselves, and for discord you can find them here https://discord.com/developers/docs/legal
From the same page this is what you should be concerned with:
- LICENSE, ACCOUNTS AND RESTRICTIONS
2.1 API or SDK License.
Subject to the terms and conditions of this Agreement, Discord grants you a limited, non-exclusive, revocable, non-transferable license to access and use the API or SDK solely to as necessary to (i) develop, test, display and execute your Applications with the API or SDK functionality included; and (ii) distribute to third parties, or permit third parties to access, the API or SDK as integrated into your Applications.
You shall not, and shall not permit any person, directly or indirectly, to (i) reverse engineer, disassemble, reconstruct, decompile, translate, modify or copy the API or SDK, other than as explicitly permitted hereunder (except to the extent the foregoing restriction is expressly prohibited by applicable law notwithstanding this limitation), (ii) create derivative works of the API or SDK or any aspect or portion thereof, including without limitation, source code and algorithms, (iii) distribute or otherwise disseminate the API or SDK by any means or in any form, except as an integral part of your Applications; (iv) use the API or SDK in connection with any Applications that include any malware or other harmful code or that facilitate spamming in any way; (v) circumvent any limits or any privacy or access controls (or attempt to do so); or (vi) include any advertisements or other promotions within the functionality enabled by the API or SDK. Except as expressly set forth in this Agreement, Discord reserves all rights in or the API and SDK.
As long as you are doing any of that, you will be able to use the API in an open source application.
API is just that, an API, its not source code. It is a way that your application is able to communicate with another so its not covered by source code license but has its own license terms.
P.S. I am in not a lawyer but I recommend that you read through those license terms.
Hope this helps.