Inventory Management API
Overview
Base URL
https://api.inventory.com/v1Authentication
Endpoints
GET /products
Authorization: Bearer <your_api_key>https://api.inventory.com/v1Authorization: Bearer <your_api_key>{
"products": [
{
"id": 101,
"name": "Product 1",
"category": "Category A"
},
{
"id": 102,
"name": "Product 2",
"category": "Category B"
}
]
}Content-Type: application/json
Authorization: Bearer <your_api_key>{
"name": "New Product",
"category": "Category A"
}{
"id": 103,
"name": "New Product",
"category": "Category A"
}{
"error": "Invalid product data"
}Content-Type: application/json
Authorization: Bearer <your_api_key>{
"name": "Updated Product",
"category": "Category A"
}{
"id": 101,
"name": "Updated Product",
"category": "Category A"
}{
"error": "Product not found"
}Authorization: Bearer <your_api_key>{
"message": "Product deleted successfully."
}{
"error": "Product not found"
}import requests
url = "https://api.inventory.com/v1/products"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <your_api_key>"
}
data = {
"name": "New Product",
"category": "Category A"
}
response = requests.post(url, json=data, headers=headers)
print(response.json())const fetch = require('node-fetch');
const url = 'https://api.inventory.com/v1/products';
const options = {
method: 'GET',
headers: {
'Authorization': 'Bearer <your_api_key>'
}
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));