API Documentation- Widget Commentory
NOTE To READERS: All online docs failed me for parsing so using Medium as a scratchpad, ignore this article
Create Widget
Create a new widget in the system.
Request
curl -X POST ‘https://api.example.com/v1/widgets' \
— header ‘Authorization: Bearer YOUR_TOKEN’ \
— header ‘Content-Type: application/json’ \
— data ‘{
“name”: “Super Widget”,
“description”: “A powerful widget for all your needs”,
“category”: “premium”,
“price”: 99.99,
“features”: [“fast”, “reliable”, “scalable”]
}’
Read Widget
Retrieve a specific widget by ID.
Request
curl -X GET ‘https://api.example.com/v1/widgets/w_123456' \
— header ‘Authorization: Bearer YOUR_TOKEN’
Update Widget
Update an existing widget’s information.
Request
curl -X PUT ‘https://api.example.com/v1/widgets/w_123456' \
— header ‘Authorization: Bearer YOUR_TOKEN’ \
— header ‘Content-Type: application/json’ \
— data ‘{
“name”: “Super Widget Pro”,
“description”: “Now with extra features”,
“category”: “premium”,
“price”: 149.99,
“features”: [“fast”, “reliable”, “scalable”, “cloud-enabled”]
}’
Delete Widget
Remove a widget from the system.
Request
curl -X DELETE ‘https://api.example.com/v1/widgets/w_123456' \
— header ‘Authorization: Bearer YOUR_TOKEN’
Each endpoint requires authentication via Bearer token and returns standard HTTP status codes:
- 200: Success
- 201: Created (for POST requests)
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 500: Server Error