Cosmos collection elements API
The elements in a Cosmos collection, 40 a page.
GET /v1/cosmos/clusters/posts1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/cosmos/clusters/posts?url=https://www.cosmos.so/cosmos/genesis",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "data": [ { "__typename": "MediaElementTile", "id": 525622993, "createdAt": "2024-10-24T16:10:53.53411Z", "shareUrl": "https://www.cosmos.so/e/525622993", "ownerId": 108564255, "owner": { "username": "cosmos", "fullName": "Cosmos" }, "generatedCaption": { "text": "<n>Transfiguration</n> (2013) by <n>Robert Gligorov</n>." }, "source": { "url": "https://www.instagram.com/p/DBg1URJRALi/?igsh=MXZqempxa3NyenI3dw==", "isPublicDomain": false, "author": { "username": "cosmos", "fullName": "Cosmos", "profileUrl": "https://www.instagram.com/cosmos" } }, "media": { "__typename": "StaticImage", "url": "https://cdn.cosmos.so/bfce650b-3e5e-47a1-b1ce-fa9347c6e97b", "width": 1080, "height": 1080, "aiGenerated": false }, "product": null, "hasMoreMedia": true, "multipleMedia": [ { "__typename": "StaticImage", "url": "https://cdn.cosmos.so/bfce650b-3e5e-47a1-b1ce-fa9347c6e97b", "width": 1080, "height": 1080 }, { "__typename": "StaticImage", "url": "https://cdn.cosmos.so/52f65194-bfb3-435e-a943-0ba850bd1b81", "width": 1080, "height": 1084 }, "… 3 more" ] }, { "__typename": "MediaElementTile", "id": 1120226541, "createdAt": "2024-02-25T18:14:43.455664Z", "shareUrl": "https://www.cosmos.so/e/1120226541", "ownerId": null, "owner": null, "generatedCaption": { "text": "<n>The Bridges I Burn</n> (2015) by artist <n>Collin McAdoo</n>." }, "source": null, "media": { "__typename": "StaticImage", "url": "https://cdn.cosmos.so/898f21dd-0f64-4ebd-b2cf-b0720beb75f9", "width": 466, "height": 750, "aiGenerated": false }, "product": null, "hasMoreMedia": false, "multipleMedia": [] }, "… 38 more" ], "meta": { "result_count": 40, "count": 201, "next_token": "eyJ2MSI6MTYxLjAsInYyIjo2MjAxMTd9" }}Parameters
| Name | Type | Description |
|---|---|---|
urlquery · required | string | A collection URL (cosmos.so/<user>/<slug>) or user/slug. Example: https://www.cosmos.so/cosmos/genesis. |
afterquery | string | The previous page’s meta.next_token. |
Response fields
200 with a CosmosElements, in Cosmos’s own JSON.
| Field | Type | Description |
|---|---|---|
data | CosmosElement[] | |
meta | object |
Status codes
| Status | Meaning |
|---|---|
200 | A page of elements. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The user, element or collection does not exist. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Cosmos is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
How many a page?
40.
Cosmos is a trademark of Cosmos. We are not affiliated with or endorsed by Cosmos.