These snippets match the Pionia Shop tutorial. Copy them as starting points for the store API on port 8000.
Pick your learning path
Try the tutorial
Build the services behind these curls.
Moonlight overview
How service and action map to HTTP.
What these examples cover
| Example | Action | Learn more |
|---|---|---|
| Ping | Health check | Introduction |
| List products | product.list | Tutorial |
| Create product | product.create | Validation |
| Customer login | customer.login | JWT |
| Place order | order.place | Protecting actions |
Ping
curl -s http://127.0.0.1:8000/api/v1/pingList products
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-d '{"service":"product","action":"list"}'Result
{
"returnCode": 0,
"returnMessage": "OK",
"returnData": {
"products": [
{ "id": 1, "name": "Ada Mug", "price": 24.5, "stock": 12 }
]
}
}Create product (authenticated)
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"service":"product","action":"create","name":"Tote Bag","price":18,"stock":40}'Customer login
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-d '{"service":"customer","action":"login","email":"ada@pionia.shop","password":"secret"}'Result
{
"returnCode": 0,
"returnMessage": "Logged in",
"returnData": { "token": "eyJhbGciOiJIUzI1NiJ9..." }
}Place order (authenticated)
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"service":"order","action":"place","product_id":1,"quantity":2}'Wallet balance
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"service":"wallet","action":"balance"}'