Skip to content

External API

Mogens Heller Grabe edited this page Sep 25, 2020 · 5 revisions

Fleet Manager has an external HTTP API, which you may use to write your own integrations.

The API publishes metadata about itself in Swagger form, and it auto-generates a web page with documentation about which operations are available.

You can view the Swagger docs by visiting the /swagger URL beneath Fleet Manager's root URL – here are some links for the cloud-hosted Fleet Manager:

To get started using the API, you'll need an access token, which may be generated in "Team Setup" on the "External API" tab. The token must be passed to the API in the Authorization HTTP header field with the Bearer prefix – in C#, you would do it like this:

using var client = new HttpClient
{
    BaseAddress = new Uri("https://manager.rebus.fm"),
    DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Bearer", accessToken) }
};

var uri = $"ui/external/failed-messages/counts?accountId={HttpUtility.UrlEncode(accountId)}";
var json = await client.GetStringAsync(uri);

var response = JObject.Parse(json);

// do stuff with the response here 🙂 – in this example, it could be this:
// {"active": 5, "archived": 221}

assuming that accessToken and accountId are variables with appropriate values.

If you want to "hit the ground running" in using the external API, you might want to check out the terrific NSwag project – it has a code generator, which you may use to generate a strongly-typed .NET client library from Fleet Manager's swagger.json link.