Media with the Python SDK
The Python SDK has no media resource. uploads.photos and uploads.video accept a list of strings, and each string is either a media library ID or a public https:// URL.
How do I post media I already host?
Pass the URL:
python
client.uploads.photos(
connections=["instagram-mybrand"],
medias=["https://cdn.example.com/launch.jpg"],
text="Launch day",
)The URL must be publicly reachable by Socifyr.
How do I upload a local file from Python?
The SDK has no upload method. The REST endpoint is POST /media/upload with a multipart form field named file. Call it with requests and the same headers the SDK uses. The response data is a media item with an id:
python
import os
import requests
from socifyr import Socifyr
API = "https://api.socifyr.com/api"
headers = {
"Authorization": f"Bearer {os.environ['SOCIFYR_API_KEY']}",
"X-Workspace-Id": os.environ["SOCIFYR_WORKSPACE_ID"],
}
with open("banner.jpg", "rb") as f:
r = requests.post(f"{API}/media/upload", headers=headers, files={"file": ("banner.jpg", f)})
r.raise_for_status()
media = r.json()["data"] # {"id": "...", "url": "...", "type": "image", ...}
client = Socifyr()
client.uploads.photos(connections=["instagram-mybrand"], medias=[media["id"]])The media item fields (id, name, mimeType, sizeBytes, url, type, createdAt) are documented in the Media API.
How do I list or delete media from Python?
Not with the SDK. Use the Media API, the TypeScript SDK media resource, the CLI (socifyr media) or the dashboard.