Skip to main content

SDKs & Client Libraries

PostBoost provides auto-generated client libraries for 9 languages, all generated from the OpenAPI spec using OpenAPI Generator.

Available SDKs​

LanguagePackageGenerator
Pythonpostboostpython
PHPpostboost/php-sdkphp
Node.js / TypeScriptpostboosttypescript-node
Gopostboost-gogo
Rubypostboostruby
Javacom.postboost:postboost-java-sdk (not on a registry yet: build from source)java
C# / .NETPostBoost.Clientcsharp
Rustpostboostrust
Bash (CLI)postboost-clibash

Python​

pip install postboost

List accounts​

from postboost import ApiClient, Configuration
from postboost.api.accounts_api import AccountsApi

config = Configuration(access_token="YOUR_API_TOKEN")
with ApiClient(config) as client:
api = AccountsApi(client)
accounts = api.list_accounts(workspace_uuid="YOUR_WORKSPACE_UUID")
account_id = accounts.data[0].id
print(account_id)

Create a post​

from postboost import ApiClient, Configuration
from postboost.api.posts_api import PostsApi
from postboost.models import PostInput, PostVersion, PostContent

config = Configuration(access_token="YOUR_API_TOKEN")
with ApiClient(config) as client:
api = PostsApi(client)
post = api.create_post(
workspace_uuid="YOUR_WORKSPACE_UUID",
post_input=PostInput(
accounts=[account_id],
versions=[PostVersion(
account_id=0,
is_original=True,
content=[PostContent(body="Hello from PostBoost Python SDK!")]
)],
schedule_now=True,
)
)
print(post.uuid)

PHP​

composer require postboost/php-sdk

List accounts​

use PostBoostClient\Api\AccountsApi;
use PostBoostClient\Configuration;

$config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_API_TOKEN');
$httpClient = new GuzzleHttp\Client();

$accountsApi = new AccountsApi($httpClient, $config);
$accounts = $accountsApi->listAccounts($workspaceUuid);
$accountId = $accounts->getData()[0]->getId();

Create a post​

use PostBoostClient\Api\PostsApi;
use PostBoostClient\Model\PostInput;
use PostBoostClient\Model\PostVersion;
use PostBoostClient\Model\PostContent;

$postsApi = new PostsApi($httpClient, $config);
$post = $postsApi->createPost($workspaceUuid, new PostInput([
'accounts' => [$accountId],
'versions' => [new PostVersion([
'account_id' => 0,
'is_original' => true,
'content' => [new PostContent(['body' => 'Hello from PostBoost PHP SDK!'])],
])],
'schedule_now' => true,
]));
echo $post->getUuid();

Node.js / TypeScript​

npm install postboost

List accounts​

import { AccountsApi } from 'postboost';

const accountsApi = new AccountsApi();
accountsApi.accessToken = process.env.POSTBOOST_API_TOKEN!;

const result = await accountsApi.listAccounts(workspaceUuid);
const accountId = result.body.data![0].id;

Create a post​

import { PostsApi } from 'postboost';

const postsApi = new PostsApi();
postsApi.accessToken = process.env.POSTBOOST_API_TOKEN!;
const post = await postsApi.createPost(workspaceUuid, {
accounts: [accountId],
versions: [{ accountId: 0, isOriginal: true, content: [{ body: 'Hello from PostBoost Node.js SDK!' }] }],
scheduleNow: true,
});
console.log(post.body.uuid);

Go​

go get github.com/postboost-co/postboost-go

List accounts​

import postboost "github.com/postboost-co/postboost-go"

cfg := postboost.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+apiToken)
client := postboost.NewAPIClient(cfg)

accounts, _, err := client.AccountsAPI.ListAccounts(ctx, workspaceUuid).Execute()
accountID := accounts.Data[0].Id

Create a post​

post, _, err := client.PostsAPI.CreatePost(ctx, workspaceUuid).
PostInput(postboost.PostInput{
Accounts: []int32{accountID},
Versions: []postboost.PostVersion{{
AccountId: 0,
IsOriginal: true,
Content: []postboost.PostContent{{Body: postboost.PtrString("Hello from PostBoost Go SDK!")}},
}},
ScheduleNow: postboost.PtrBool(true),
}).Execute()

Ruby​

gem install postboost

List accounts​

require 'postboost'

PostBoost.configure { |c| c.access_token = ENV['POSTBOOST_API_TOKEN'] }

accounts_api = PostBoost::AccountsApi.new
accounts = accounts_api.list_accounts(workspace_uuid)
account_id = accounts.data[0].id

Create a post​

posts_api = PostBoost::PostsApi.new
post = posts_api.create_post(workspace_uuid, PostBoost::PostInput.new(
accounts: [account_id],
versions: [PostBoost::PostVersion.new(
account_id: 0,
is_original: true,
content: [PostBoost::PostContent.new(body: 'Hello from PostBoost Ruby SDK!')]
)],
schedule_now: true
))
puts post.uuid

Java​

Not on a package registry yet

The Java SDK is not published to Maven Central or GitHub Packages yet. Build it from source into your local Maven repository, then depend on it as usual.

Replace LATEST_VERSION with the newest postboost-java release tag, without the leading v.

git clone --branch vLATEST_VERSION https://github.com/postboost-co/postboost-java.git
cd postboost-java
./gradlew publishToMavenLocal # or: mvn clean install
<!-- Maven -->
<dependency>
<groupId>com.postboost</groupId>
<artifactId>postboost-java-sdk</artifactId>
<version>LATEST_VERSION</version>
</dependency>

Gradle projects need mavenLocal() in repositories and implementation 'com.postboost:postboost-java-sdk:LATEST_VERSION'.

List accounts​

import com.postboost.api.AccountsApi;
import com.postboost.ApiClient;
import java.util.UUID;

ApiClient client = new ApiClient();
client.setBearerToken(apiToken);
UUID workspaceUuid = UUID.fromString("YOUR_WORKSPACE_UUID");

AccountsApi accountsApi = new AccountsApi(client);
// keyword, group, providers, unauthorized: null = no filter
Integer accountId = accountsApi.listAccounts(workspaceUuid, null, null, null, null).getData().get(0).getId();

Create a post​

import com.postboost.api.PostsApi;
import com.postboost.model.*;

PostsApi postsApi = new PostsApi(client);
CreatePost201Response post = postsApi.createPost(workspaceUuid, new PostInput()
.addAccountsItem(accountId)
.addVersionsItem(new PostVersion()
.accountId(0)
.isOriginal(true)
.addContentItem(new PostContent().body("Hello from PostBoost Java SDK!")))
.scheduleNow(true), null); // null = no Idempotency-Key
System.out.println(post.getUuid());

C# / .NET​

dotnet add package PostBoost.Client

List accounts​

using PostBoost.Client.Api;
using PostBoost.Client.Client;
using PostBoost.Client.Model;

var config = new Configuration { AccessToken = apiToken };
var workspaceUuid = Guid.Parse("YOUR_WORKSPACE_UUID");

var accountsApi = new AccountsApi(config);
var accounts = await accountsApi.ListAccountsAsync(workspaceUuid);
var accountId = accounts.Data[0].Id;

Create a post​

var postsApi = new PostsApi(config);
var post = await postsApi.CreatePostAsync(workspaceUuid, new PostInput(
accounts: new List<int> { accountId },
versions: new List<PostVersion> {
new PostVersion(accountId: 0, isOriginal: true,
content: new List<PostContent> { new PostContent(body: "Hello from PostBoost C# SDK!") })
},
scheduleNow: true
));
Console.WriteLine(post.Uuid);

Rust​

[dependencies]
postboost = "1" # any 1.x release, Cargo picks the newest

List accounts​

use postboost::apis::accounts_api;
use postboost::apis::configuration::Configuration;

let mut config = Configuration::new();
config.bearer_access_token = Some(api_token.to_string());

// keyword, group, providers, unauthorized: None = no filter
let accounts = accounts_api::list_accounts(&config, &workspace_uuid, None, None, None, None).await?;
let account_id = accounts.data.unwrap_or_default()[0].id;

Create a post​

use postboost::apis::posts_api;
use postboost::models::{PostInput, PostVersion, PostContent};

let post_input = PostInput {
accounts: Some(vec![account_id]),
versions: vec![PostVersion {
account_id: 0,
is_original: true,
content: vec![PostContent {
body: Some("Hello from PostBoost Rust SDK!".to_string()),
..Default::default()
}],
..Default::default()
}],
schedule_now: Some(true),
..Default::default()
};

// None = no Idempotency-Key
let post = posts_api::create_post(&config, &workspace_uuid, post_input, None).await?;
println!("{}", post.uuid);

Bash CLI​

# Download latest release
curl -LO https://github.com/postboost-co/postboost-cli/releases/latest/download/postboost-cli.tar.gz
tar xzf postboost-cli.tar.gz

# Keep the token in a variable; the CLI takes it as an Authorization header argument
export POSTBOOST_API_TOKEN="YOUR_API_TOKEN"

Every call needs --host https://postboost.co. Path parameters go in as name=value and headers as "Name: value", after the operation name.

List accounts​

./postboost-cli --host https://postboost.co listAccounts \
workspaceUuid=your-workspace-uuid \
"Authorization: Bearer $POSTBOOST_API_TOKEN"

Create a post​

./postboost-cli --host https://postboost.co createPost \
workspaceUuid=your-workspace-uuid \
"Authorization: Bearer $POSTBOOST_API_TOKEN" - <<'JSON'
{"accounts":[42],"versions":[{"account_id":0,"is_original":true,"content":[{"body":"Hello from PostBoost CLI!"}]}],"schedule_now":true}
JSON

The - argument makes the CLI read the JSON body from standard input.


Next steps​

Generating SDKs yourself​

All SDKs are generated from the OpenAPI spec. You can regenerate them at any time:

# Clone the PostBoost repo and install the generator
npm install @openapitools/openapi-generator-cli

# Generate all SDKs
make sdks

# Or a specific language
make sdk-python

Requires Java 11+.

Open source and contributing​

Every SDK and the CLI live in the postboost-co GitHub organisation under the MIT licence. Each repository has a CONTRIBUTING guide, issue templates and a security policy.

  • Wrong field, type or missing endpoint: open an issue in the SDK's repository. We fix it in the OpenAPI spec and the next release regenerates every SDK.
  • Security issues: email [email protected] instead of opening a public issue.