Skip to content
Open
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
9 changes: 6 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This is a serverless AWS Lambda application for generating marketplace listings

**Core Components:**
- `generate_listing_lambda.py` - Main Lambda handler that orchestrates the image processing pipeline
- `place_listing_lambda.py` - Posts the generated listing to the Marktplaats API
- `rekognition_utils.py` - AWS Rekognition integration for image analysis (label detection and text extraction)
- The serverless configuration references a `handler.py` module that is not present.

Expand Down Expand Up @@ -41,7 +42,8 @@ pip install -r marktplaats-backend/requirements.txt

**Deploy to AWS:**
```bash
export MARKTPLAATS_TOKEN=your_api_token
export MARKTPLAATS_CLIENT_ID=your_client_id
export MARKTPLAATS_CLIENT_SECRET=your_client_secret
cd marktplaats-backend
./deploy.sh
```
Expand Down Expand Up @@ -71,6 +73,7 @@ Update the S3 bucket name in both:
- `generate_listing_lambda.py:9` (`s3_bucket` variable)
- `serverless.yaml:10` (`S3_BUCKET` environment variable)

Set your Marktplaats API token via the `MARKTPLAATS_TOKEN` environment
variable so that `category_matcher.py` can authenticate to the API.
Set your Marktplaats API credentials via the `MARKTPLAATS_CLIENT_ID` and
`MARKTPLAATS_CLIENT_SECRET` environment variables so that the lambdas can
authenticate to the API.

33 changes: 33 additions & 0 deletions marktplaats-backend/place_listing_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json
import requests

from marktplaats_auth import get_marktplaats_access_token

MARKTPLAATS_API_BASE = "https://api.marktplaats.nl/v1"


def create_marktplaats_listing(listing):
"""Send the listing data to the Marktplaats API."""
token = get_marktplaats_access_token()
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
"Accept": "application/json",
"Accept-Language": "nl-NL",
}
response = requests.post(
f"{MARKTPLAATS_API_BASE}/listings",
headers=headers,
json=listing,
)
response.raise_for_status()
return response.json()


def lambda_handler(event, context):
try:
body = json.loads(event["body"])
result = create_marktplaats_listing(body)
return {"statusCode": 200, "body": json.dumps(result)}
except Exception as e:
return {"statusCode": 500, "body": json.dumps({"error": str(e)})}
7 changes: 7 additions & 0 deletions marktplaats-backend/serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ functions:
path: generate-listing
method: post
cors: true
placeListing:
handler: place_listing_lambda.lambda_handler
events:
- http:
path: place-listing
method: post
cors: true

plugins:
- serverless-python-requirements
Expand Down