Skip to content

Instantly share code, notes, and snippets.

@fdciabdul
Created June 25, 2024 10:39
Show Gist options
  • Select an option

  • Save fdciabdul/69d64131361cceea005a37fd98d167bd to your computer and use it in GitHub Desktop.

Select an option

Save fdciabdul/69d64131361cceea005a37fd98d167bd to your computer and use it in GitHub Desktop.
Welcome file

Example cURL Commands

Here are some example cURL commands to interact with the API:

  1. Create a User

    sh

    Copy code

    curl -X POST http://localhost:3000/users \ -H "Content-Type: application/json" \ -d '{ "email": "newuser@mail.com", "password": "newpassword1234", "name": "New User" }'

  2. Get All Users

    sh

    Copy code

    curl -X GET http://localhost:3000/users

  3. Get User by ID

    sh

    Copy code

    curl -X GET http://localhost:3000/users/1

  4. Update a User

    sh

    Copy code

    curl -X PUT http://localhost:3000/users/1 \ -H "Content-Type: application/json" \ -d '{ "email": "updateduser@mail.com", "password": "updatedpassword1234", "name": "Updated User" }'

  5. Delete a User

    sh

    Copy code

    curl -X DELETE http://localhost:3000/users/1

  6. Create a Feed Stock

    sh

    Copy code

    curl -X POST http://localhost:3000/feed-stocks \ -H "Content-Type: application/json" \ -d '{ "stock": 100 }'

  7. Get All Feed Stocks

    sh

    Copy code

    curl -X GET http://localhost:3000/feed-stocks

  8. Get Feed Stock by ID

    sh

    Copy code

    curl -X GET http://localhost:3000/feed-stocks/1

  9. Update a Feed Stock

    sh

    Copy code

    curl -X PUT http://localhost:3000/feed-stocks/1 \ -H "Content-Type: application/json" \ -d '{ "stock": 200 }'

  10. Delete a Feed Stock

sh

Copy code

`curl -X DELETE http://localhost:3000/feed-stocks/1` 
  1. Create a Transaction
sh

Copy code

`curl -X POST http://localhost:3000/transactions \
-H "Content-Type: application/json" \
-d '{
    "feed_stock_change": -1,
    "chicken_count": 100,
    "type": "DEP",
    "location": "Location A"
}'` 
  1. Get All Transactions
sh

Copy code

`curl -X GET http://localhost:3000/transactions` 
  1. Get Transaction by ID
sh

Copy code

`curl -X GET http://localhost:3000/transactions/1` 
  1. Update a Transaction
sh

Copy code

`curl -X PUT http://localhost:3000/transactions/1 \
-H "Content-Type: application/json" \
-d '{
    "feed_stock_change": 0,
    "chicken_count": 150,
    "type": "WITH",
    "location": "Location B"
}'` 
  1. Delete a Transaction
sh

Copy code

`curl -X DELETE http://localhost:3000/transactions/1` 

This documentation provides a comprehensive overview of the REST API endpoints, methods, request bodies, responses, and sample cURL commands for interacting with the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment