mastodonpp is a C++ wrapper for the Mastodon and Pleroma APIs. It replaces mastodon-cpp.
Important
|
mastodonpp is in maintenance mode. I will continue to fix bugs, but won’t add new features. If you’d like to adopt this project, please get in touch. |
We aim to create a library that is comfortable, yet minimal. All API endpoints
from Mastodon and Pleroma are stored in enum class
es, to counteract typos
and make your life easier. The network-facing code is built on
libcurl, a mature and stable library that is available on
most operating systems. The library does not parse the responses itself, but
returns to you the raw data, because we know everyone has their favorite JSON
library and we don’t want to impose our choice on you!
Here is a rough overview of the features:
-
✓
GET
, StreamingGET
,POST
,PATCH
,PUT
andDELETE
requests. -
✓ Comfortable access to pagination headers.
-
✓ Report maximum allowed character per post.
-
✓ Simple function to register a new “app” (get an access token).
-
✓ Report which mime types are allowed for posting statuses.
-
✓ Find and retrieve NodeInfo.
-
✓ Easy access to the libcurl handle for maximum configurability.
-
✓ Set proxy server, User-Agent and the path to the CA bundle.
Have a look at the reference.
#include <mastodonpp/mastodonpp.hpp>
#include <iostream>
int main()
{
mastodonpp::Instance instance{"example.com", "123AccessToken123"};
instance.set_proxy("socks4a://[::1]:9050");
mastodonpp::Connection connection{instance};
const mastodonpp::parametermap parameters
{
{"status", "How is the weather?"},
{"poll[options]", vector<string_view>{"Nice", "not nice"}},
{"poll[expires_in]", "86400"}
};
auto answer{connection.post(mastodonpp::API::v1::statuses, parameters)};
if (answer)
{
std::cout << answer << std::endl;
}
}
More examples are included in the reference.
eselect repository enable guru
echo 'dev-cpp/mastodonpp' >> /etc/portage/package.accept_keywords/mastodonpp
emaint sync -r guru
emerge -a dev-cpp/mastodonpp
The git-version is available via the AUR: https://aur.archlinux.org/packages/mastodonpp-git/.
We automatically generate packages for Debian buster (10) and Ubuntu bionic (18.04), but only for x86_64 (amd64). Download them at schlomp.space.
apt install ./libmastodonpp*.deb
We automatically generate packages for CentOS 8, but only for x86_64 (amd64). Download them at schlomp.space.
yum install ./libmastodonpp*.rpm
Download the current release at schlomp.space.
mkdir -p build && cd build
cmake ..
cmake --build . -- -j$(nproc --ignore=1)
-
-DCMAKE_BUILD_TYPE=Debug
for a debug build. -
-DWITH_TESTS=YES
if you want to compile the tests. -
-DWITH_EXAMPLES=YES
if you want to compile the examples. -
-DWITH_DOC=YES
if you want to generate the API documentation. -
-DWITH_CLANG-TIDY=YES
to check the sourcecode with clang-tidy while compiling. -
One of:
-
-DWITH_DEB=YES
if you want to be able to generate a deb-package. -
-DWITH_RPM=YES
if you want to be able to generate an rpm-package.
-
To create a deb or rpm package, run make package
after compiling.
mastodonpp has been reported to compile with MinGW GCC, but
http_method::DELETE
has to be renamed, because Windows headers define a
DELETE
macro.