Analytics
Workspace statistics
Posts due in a window by status, publishes per platform by status, and the accounts and stored media now.
GET
/v1/statsTL;DR
| Question | Answer |
|---|---|
| What does it do? | Workspace statistics. |
| What does it need? | An API key or an OAuth access token. |
| What does it take? | from, to in the query string. |
| What does it return? | Status 200 with a body of type Stats. |
| In the SDK? | flung.analytics.stats() |
| What can go wrong? | 401 Missing, unknown, revoked or expired API key; 422 The request failed validation; 429 Too many requests for this credential; wait for retry-after seconds. Every failure has the same error shape. |
What it does
Posts due in a window by status, publishes per platform by status, and the accounts and stored media now. The window defaults to the last 30 days.
Example
bash
curl -X GET 'https://api.flung.dev/v1/stats' \ --header "Authorization: Bearer $FLUNG_API_KEY"ts
import { Flung } from '@flung.dev/sdk'
const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })const result = await flung.analytics.stats()js
const response = await fetch('https://api.flung.dev/v1/stats', { method: 'GET', headers: { 'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`, },})if (!response.ok) throw new Error((await response.json()).error.message)const result = await response.json()A successful answer looks like this:
json
{ "from": "string", "to": "string", "posts": { "published": 40, "failed": 2, "scheduled": 5 }, "platforms": [ { "platform": "x", "targets": {} } ], "accounts": [ { "platform": "x", "accounts": {} } ], "media": { "files": 1, "bytes": 1 }}Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
from | string | no | |
to | string | no |
Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | The statistics. | Stats |
| 401 | Missing, unknown, revoked or expired API key. | Error |
| 422 | The request failed validation. | Error |
| 429 | Too many requests for this credential; wait for retry-after seconds. | Error |
Response body
A 200 answer has the type Stats.
| Field | Type | Required | Description |
|---|---|---|---|
from | string | yes | |
to | string | yes | |
posts | object | yes | Posts due in the window, by status. |
platforms | object[] | yes | |
platforms[].platform | Platform | yes | |
platforms[].targets | object | yes | Publishes to accounts on this platform, by status. |
accounts | object[] | yes | |
accounts[].platform | Platform | yes | |
accounts[].accounts | object | yes | Accounts now, by status. |
media | object | yes | |
media.files | integer | yes | |
media.bytes | integer | yes |
See also
| Doc | Why |
|---|---|
| API reference | Every endpoint |
| Schemas | Every request and response type |
| Errors | Every error code and what to do about it |