Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ All notable changes to `fopost` are documented here.

### Added

- `client.designs`: `list`, `create`, `get`, `update` (returns a `DesignSaveResult` with the
`design` and the saved `version`), `delete`, `versions` (`include_document=True` adds
each version's document), `restore_version`, `duplicate`, `export` (`png`, `jpg`, `pdf`,
`mp4` or `gif` into the media library), `bulk_create` (one design per row), `posts`,
`text_to_slides` and `from_post`. The design `document` is a plain dict.
- `client.fonts`: `list` (the built-in library plus a workspace's uploads), `upload` (a
path, an open binary file, or `(filename, bytes, mime_type)`) and `delete`.
- `client.video_edits`: `ops`, `list`, `create` with `operations` as
`{"op": ..., "params": {...}}` dicts or `VideoEditOperation`s, and `get`.
- `media.generate_alt_text(media_id)` returns an `AltTextResult`. Uses AI credits.
- Models `Design`, `DesignVersion`, `DesignSaveResult`, `DesignDeleteResult`,
`DesignExport`, `DesignExportFile`, `DesignPost`, `TextToSlidesResult`, `SlideCover`,
`SlidePoint`, `SlidesBrand`, `FontList`, `LibraryFont`, `LibraryFontFile`,
`UploadedFont`, `VideoEdit`, `VideoEditOperation`, `VideoEditOpInfo`,
`VideoEditResultMedia`, `VideoEditOutput`, `AltTextResult`, and the tuples
`DESIGN_KINDS`, `VIDEO_EDIT_OPS`, `VIDEO_EDIT_STATUSES`.
- `posts.validate_bulk_import` and `posts.commit_bulk_import` take an optional `accounts`
list (account ids or platform names), sent comma-separated and applied to every CSV row
whose own `accounts` cell is empty.
Expand Down
7 changes: 5 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ src/fopost/
posts.py accounts.py account_groups.py workspaces.py labels.py ai.py
inbox.py contacts.py broadcasts.py ads.py media.py analytics.py
queue.py connect_sessions.py webhook_endpoints.py automations.py logs.py
designs.py fonts.py video_edits.py
```

Request flow: a resource method builds a snake_case body/params dict, calls
Expand Down Expand Up @@ -116,12 +117,14 @@ preflight/unpublish/deliveries, bulk import validate/commit/rollback, `schedule=
create and update), accounts (list/get/health/update/move, X communities, Telegram connect code
and bot commands, Slack channels, members and posting identity, …), account_groups
(list/create/get/update/delete/set_members), workspaces (list/get/create/update/delete), labels
(list/create/get/update/delete), media (list/upload/delete/limits/presign/complete/upload_direct),
(list/create/get/update/delete), media (list/upload/delete/limits/presign/complete/upload_direct/generate_alt_text),
ai (credits/generate_caption/rewrite/repurpose_url), inbox (the `/v1/inbox` family except the X
Chat routes), ads (the `/v1/ads` family), validate (post/length/media), analytics (dashboard
reads plus decay/frequency/timeline/changes), queue (slots CRUD, next, preview), connect_sessions
(create/get), webhook_endpoints (CRUD, test, deliveries, redeliver), automations (CRUD, toggle,
stats, versions, runs), logs (list). **`client.webhook_endpoints` manages outbound endpoints;
stats, versions, runs), logs (list), designs (CRUD, versions, restore, duplicate, export, bulk,
posts, text-to-slides, from-post; `document` is a plain dict), fonts (list/upload/delete),
video_edits (ops/list/create/get; no wait helper). **`client.webhook_endpoints` manages outbound endpoints;
`fopost.webhooks` (the module) verifies the deliveries they receive** — the names differ on
purpose so `from fopost import webhooks` keeps meaning the verifier. The checker in
`fopost-api-collections` (`scripts/sdk-gaps.mjs`) must report no gap before a release. Adding a
Expand Down
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,41 @@ The SDK picks the route: when every file fits in a multipart request it sends on
otherwise it uploads each file directly and attaches the results before sending the
post. On `update` with no `content`, the files are appended to the post's first block.

## Designs and video edits

A design's `document` is the editor document, sent and returned as a plain dict.
`update` and `restore_version` return a `DesignSaveResult` with the `design` and the
`version` that call saved, if any. `export` renders pages into the media library:

```python
design = client.designs.create(workspace_id=workspace.id, kind="post", name="Launch")
client.designs.update(design.id, document=document, create_version=True)
export = client.designs.export(design.id, format="png")
print([f.media_id for f in export.files])
```

`fonts.upload` takes a path, an open binary file, or `(filename, bytes, mime_type)`:

```python
font = client.fonts.upload(workspace_id=workspace.id, file="BrandSans-Bold.woff2", weight=700)
```

A video edit runs a library video through `operations` in order and finishes in the
background. `video_edits.ops()` lists every operation and whether it uses AI credits;
poll `get` until `status` is `succeeded` or `failed`:

```python
edit = client.video_edits.create(
media_id=video.id,
operations=[{"op": "trim", "params": {"start": 0, "end": 30}}, {"op": "denoise"}],
)
edit = client.video_edits.get(edit.id)
print(edit.status, edit.result_media_id)
```

`media.generate_alt_text(media_id)` describes a library image with AI and saves it as
the item's alt text.

## Configuration

```python
Expand Down Expand Up @@ -294,7 +329,7 @@ except FopostError as err:
| `account_groups` | `list`, `create`, `get`, `update`, `delete`, `set_members` |
| `workspaces` | `list`, `get`, `create`, `update`, `delete` |
| `labels` | `list`, `create`, `get`, `update`, `delete` |
| `media` | `list`, `upload`, `delete`, `limits`, `presign`, `complete`, `upload_direct` |
| `media` | `list`, `upload`, `delete`, `limits`, `presign`, `complete`, `upload_direct`, `generate_alt_text` |
| `ai` | `credits`, `generate_caption`, `rewrite`, `repurpose_url` |
| `inbox` | `list`, `threads`, `conversations`, `unread_count`, `accounts`, `platforms`, `mark_thread_read`, `refresh`, `resolve`, `update`, `edit_comment`, `reply`, `hide`, `unhide`, `delete`, `like`, `unlike`, `repost`, `unrepost`, `bookmark`, `unbookmark`, `vote`, `pin`, `unpin`, `react`, `start_conversation`, `set_typing`, `handover`, `list_approvals`, `approve_reply`, `reject_reply` |
| `inbox` | `list`, `threads`, `conversations`, `unread_count`, `accounts`, `platforms`, `mark_thread_read`, `refresh`, `resolve`, `update`, `edit_comment`, `reply`, `hide`, `unhide`, `delete`, `like`, `unlike`, `repost`, `unrepost`, `bookmark`, `unbookmark`, `vote`, `pin`, `unpin`, `react`, `start_conversation`, `set_typing`, `list_approvals`, `approve_reply`, `reject_reply` |
Expand All @@ -315,6 +350,9 @@ except FopostError as err:
| `webhook_endpoints` | `list`, `create`, `update`, `delete`, `test`, `deliveries`, `get_delivery`, `redeliver` |
| `automations` | `list`, `create`, `get`, `update`, `delete`, `toggle`, `stats`, `versions`, `get_version`, `restore_version`, `runs`, `get_run` |
| `logs` | `list` |
| `designs` | `list`, `create`, `get`, `update`, `delete`, `versions`, `restore_version`, `duplicate`, `export`, `bulk_create`, `posts`, `text_to_slides`, `from_post` |
| `fonts` | `list`, `upload`, `delete` |
| `video_edits` | `ops`, `list`, `create`, `get` |

For an endpoint the SDK does not wrap yet, `client.request` sends an
authenticated call and hands back the decoded body:
Expand Down
48 changes: 48 additions & 0 deletions src/fopost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@
CONNECT_SESSION_STATUSES,
CONVERSION_ACTION_SOURCES,
CUSTOM_CONVERSION_EVENT_TYPES,
DESIGN_KINDS,
PIXEL_DATA_USE_SETTINGS,
PLATFORMS,
POST_STATUSES,
VIDEO_EDIT_OPS,
VIDEO_EDIT_STATUSES,
WEBHOOK_EVENTS,
AccountGroup,
AccountMove,
Expand Down Expand Up @@ -70,6 +73,7 @@
AdSource,
AiCreditBalance,
AiCredits,
AltTextResult,
AnalyticsAccountSummary,
AnalyticsCollectError,
AnalyticsCollectResult,
Expand Down Expand Up @@ -141,6 +145,13 @@
DemographicAccountRef,
DemographicBucket,
DemographicDimensions,
Design,
DesignDeleteResult,
DesignExport,
DesignExportFile,
DesignPost,
DesignSaveResult,
DesignVersion,
DiscordChannel,
DiscordIdentity,
DiscordMember,
Expand All @@ -153,6 +164,7 @@
ExternalAd,
FeedLead,
FollowerHistoryPoint,
FontList,
FrequencyBand,
FrequencyBest,
FrequencyWeek,
Expand Down Expand Up @@ -214,6 +226,8 @@
LeadPageSubscription,
LeadsFeedPage,
LeadsPage,
LibraryFont,
LibraryFontFile,
LinkedInMention,
MatchKeyCoverage,
MediaItem,
Expand Down Expand Up @@ -278,6 +292,9 @@
SlackChannel,
SlackIdentity,
SlackMember,
SlideCover,
SlidePoint,
SlidesBrand,
SocialAccount,
SparkPost,
SubredditCheck,
Expand All @@ -287,6 +304,7 @@
TelegramBotCommands,
TelegramConnectCode,
TelegramConnectStatus,
TextToSlidesResult,
TikTokCreatorInfo,
TikTokMusic,
TikTokPlace,
Expand All @@ -301,13 +319,19 @@
TopPostPlatform,
UnpublishDelivery,
UnpublishResult,
UploadedFont,
UploadLimits,
UploadLimitTier,
ValidateLengthCheck,
ValidateLengthResult,
ValidateMediaResult,
ValidatePlatformCheck,
ValidatePostResult,
VideoEdit,
VideoEditOperation,
VideoEditOpInfo,
VideoEditOutput,
VideoEditResultMedia,
WebhookDelivery,
WebhookEndpoint,
WebhookSubscription,
Expand Down Expand Up @@ -342,6 +366,30 @@
FoPost = Fopost

__all__ = [
"AltTextResult",
"DESIGN_KINDS",
"Design",
"DesignDeleteResult",
"DesignExport",
"DesignExportFile",
"DesignPost",
"DesignSaveResult",
"DesignVersion",
"FontList",
"LibraryFont",
"LibraryFontFile",
"SlideCover",
"SlidePoint",
"SlidesBrand",
"TextToSlidesResult",
"UploadedFont",
"VIDEO_EDIT_OPS",
"VIDEO_EDIT_STATUSES",
"VideoEdit",
"VideoEditOpInfo",
"VideoEditOperation",
"VideoEditOutput",
"VideoEditResultMedia",
"AccountGroup",
"AccountMove",
"AccountPrimary",
Expand Down
6 changes: 6 additions & 0 deletions src/fopost/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
BroadcastsResource,
ConnectSessionsResource,
ContactsResource,
DesignsResource,
FontsResource,
GoogleBusinessResource,
InboxResource,
KnowledgeResource,
Expand All @@ -31,6 +33,7 @@
QueueResource,
SequencesResource,
ValidateResource,
VideoEditsResource,
WebhookEndpointsResource,
WhatsappResource,
WorkspacesResource,
Expand Down Expand Up @@ -102,6 +105,9 @@ def __init__(
self.webhook_endpoints = WebhookEndpointsResource(self._http)
self.automations = AutomationsResource(self._http)
self.logs = LogsResource(self._http)
self.designs = DesignsResource(self._http)
self.fonts = FontsResource(self._http)
self.video_edits = VideoEditsResource(self._http)

@property
def base_url(self) -> str:
Expand Down
Loading
Loading