|
| 1 | +# Submit a Community Photo |
| 2 | + |
| 3 | +`POST /api/v1/libraries/{slug}/photo` |
| 4 | + |
| 5 | +Submit a community photo for an approved library. The photo starts in **pending** status and must be approved by a moderator before it appears publicly. Each user can submit up to 3 photos per library. |
| 6 | + |
| 7 | +**Auth required:** Yes (`Bearer` token) |
| 8 | + |
| 9 | +**Content type:** `multipart/form-data` |
| 10 | + |
| 11 | +## Path parameters |
| 12 | + |
| 13 | +| Parameter | Type | Description | |
| 14 | +|-----------|------|-------------| |
| 15 | +| `slug` | string | URL slug of the library to add a photo to | |
| 16 | + |
| 17 | +## Fields |
| 18 | + |
| 19 | +| Field | Type | Required | Description | |
| 20 | +|-------|------|----------|-------------| |
| 21 | +| `photo` | file | Yes | Photo of the library (JPEG/PNG/WEBP, max 8 MB) | |
| 22 | +| `caption` | string | No | Optional caption for the photo (max 200 chars) | |
| 23 | + |
| 24 | +## Examples |
| 25 | + |
| 26 | +=== "curl" |
| 27 | + |
| 28 | + ```bash |
| 29 | + curl -X POST https://bookcorners.org/api/v1/libraries/berlin-friedrichstr-12-corner-books/photo \ |
| 30 | + -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \ |
| 31 | + -F "photo=@community-photo.jpg" \ |
| 32 | + -F "caption=Summer view from the park side" |
| 33 | + ``` |
| 34 | + |
| 35 | +=== "Python" |
| 36 | + |
| 37 | + ```python |
| 38 | + import requests |
| 39 | + |
| 40 | + resp = requests.post( |
| 41 | + "https://bookcorners.org/api/v1/libraries/berlin-friedrichstr-12-corner-books/photo", |
| 42 | + headers={"Authorization": f"Bearer {access_token}"}, |
| 43 | + data={"caption": "Summer view from the park side"}, |
| 44 | + files={"photo": open("community-photo.jpg", "rb")}, |
| 45 | + ) |
| 46 | + print(resp.json()) |
| 47 | + ``` |
| 48 | + |
| 49 | +### Submit without a caption |
| 50 | + |
| 51 | +=== "curl" |
| 52 | + |
| 53 | + ```bash |
| 54 | + curl -X POST https://bookcorners.org/api/v1/libraries/berlin-friedrichstr-12-corner-books/photo \ |
| 55 | + -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \ |
| 56 | + -F "photo=@community-photo.jpg" |
| 57 | + ``` |
| 58 | + |
| 59 | +=== "Python" |
| 60 | + |
| 61 | + ```python |
| 62 | + resp = requests.post( |
| 63 | + "https://bookcorners.org/api/v1/libraries/berlin-friedrichstr-12-corner-books/photo", |
| 64 | + headers={"Authorization": f"Bearer {access_token}"}, |
| 65 | + files={"photo": open("community-photo.jpg", "rb")}, |
| 66 | + ) |
| 67 | + ``` |
| 68 | + |
| 69 | +## Response (`201 Created`) |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "id": 15, |
| 74 | + "caption": "Summer view from the park side", |
| 75 | + "status": "pending", |
| 76 | + "created_at": "2025-06-15T14:30:00Z" |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +!!! note |
| 81 | + The photo will have **pending** status. It won't appear on the library detail page until approved by a moderator. Each user can submit up to 3 photos per library (rejected photos do not count towards this limit). |
| 82 | + |
| 83 | +## Errors |
| 84 | + |
| 85 | +| Status | Cause | |
| 86 | +|--------|-------| |
| 87 | +| `400` | Invalid photo format, or per-user limit of 3 photos reached for this library | |
| 88 | +| `404` | Library not found or not in approved status | |
| 89 | +| `413` | Photo exceeds 8 MB size limit | |
| 90 | +| `422` | Request validation error | |
| 91 | +| `429` | Rate limit exceeded (see [Rate Limiting](../rate-limiting.md)) | |
0 commit comments