C++ wrapper for the Mastodon and Pleroma APIs.
Go to file
tastytea b94313294b
Fix CI recipe.
2020-01-10 20:04:09 +01:00
cmake Implement HTTP POST in CURLWrapper. 2020-01-10 13:08:34 +01:00
examples Add example: post_status.cpp. 2020-01-10 19:32:04 +01:00
include Add example03 to reference. 2020-01-10 19:40:16 +01:00
pkg-config Shorten the pkg-config file a bit. 2020-01-09 19:18:45 +01:00
src Hide CURLWrapper::cancel_stream(). 2020-01-10 18:57:42 +01:00
tests Add test for Connection. 2020-01-10 19:09:25 +01:00
.drone.yml Fix CI recipe. 2020-01-10 20:04:09 +01:00
.editorconfig Add skeleton. 2020-01-03 08:32:03 +01:00
.gitignore Expand git ignores. 2020-01-03 10:20:09 +01:00
CMakeLists.txt Version bump 0.1.0. 2020-01-10 19:10:33 +01:00
CODE_OF_CONDUCT.adoc Add contributing guidelines and COC. 2020-01-03 06:30:29 +01:00
CONTRIBUTING.adoc Add contributing guidelines and COC. 2020-01-03 06:30:29 +01:00
Doxyfile Add documentation. 2020-01-03 11:27:32 +01:00
LICENSE Add license. 2020-01-03 06:29:45 +01:00
README.adoc Add installation instructions for Gentoo, Debian, Ubuntu and CentOS. 2020-01-10 19:52:36 +01:00
build_doc.sh Add documentation. 2020-01-03 11:27:32 +01:00

README.adoc

mastodonpp

mastodonpp is a C++ wrapper for the Mastodon API. It replaces mastodon-cpp.

We aim to create a library that is comfortable, yet minimal. All API endpoints from Mastodon and Pleroma are stored in enum classes, 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 virtually every operating system. 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 dont want to impose our choice on you!

Features

This is still a work in progress; here is a rough overview of the features:

  • ❏ Requests

    • GET requests.

    • ✓ Streaming GET requests.

    • POST requests.

    • PATCH requests.

    • PUT requests.

    • DELETE requests.

  • ✓ Report maximum allowed character per post.

  • ❏ Comfortable access to pagination headers.

  • ❏ Comfortable function to register a new “app” (get an access token).

Usage

Have a look at the reference.

Example

#include "mastodonpp.hpp"
#include <iostream>

int main()
{
    mastodonpp::Instance instance{"example.com", {}};
    mastodonpp::Connection connection{instance};

    const mastodonpp::parametermap parameters
        {
            {"status", "How is the wheather?"},
            {"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.

Install

Gentoo

eselect repository enable tastytea
echo 'dev-cpp/mastodonpp' >> /etc/portage/package.accept_keywords/mastodonpp
emaint sync -r tastytea
emerge -a dev-cpp/mastodonpp

Debian and Ubuntu

We automatically generate packages for Debian buster (10) and Ubuntu bionic (18.04), but only for x86_64 (amd64). Download the them at schlomp.space.

apt install ./libmastodonpp*.deb

CentOS

We automatically generate packages for CentOS 8, but only for x86_64 (amd64). Download the them at schlomp.space.

yum install ./libmastodonpp*.rpm

From source

Dependencies

  • Tested OS: Linux

  • C++ compiler (tested: GCC 7/8/9, clang 6/7)

  • CMake (at least: 3.9)

  • libcurl (at least: 7.56)

  • Optional

    • Documentation: Doxygen (tested: 1.8)

    • Tests: Catch (tested: 2.5 / 1.2)

    • DEB package: dpkg (tested: 1.18)

    • RPM package: rpm-build (tested: 4.11)

Get sourcecode

Release

Download the current release at schlomp.space.

Development version
git clone https://schlomp.space/tastytea/mastodonpp.git

Compile

mkdir -p build && cd build
cmake ..
cmake --build . -- -j$(nproc --ignore=1)
CMake options:
  • -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.

  • 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.