Introduction

Welcome to the Nicotine Pouches API documentation. This API allows you to access and interact with our database of nicotine pouch products, reviews, and user profiles. You can use this API to integrate our services into your applications and websites.

Base URL

arduino

https://api.nicotine-pouches.org/v1/

Authentication

All requests to the Nicotine Pouches API must be authenticated using an API key. You can obtain your API key by registering on our developer portal.

Include the API key in the header of each request:

makefile

Authorization: Bearer YOUR_API_KEY

Endpoints

1. Get Products

Retrieve a list of nicotine pouch products.

URL: /products

Method: GET

Parameters:

Name Type Description
limit int Number of products to retrieve
offset int Offset for pagination
search string Search term for filtering products

Response:

json

{
"status": "success",
"data": [
{
"id": 1,
"name": "Nicotine Pouch 1",
"brand": "Brand A",
"price": 4.99,
"rating": 4.5
},
...
]
}

Example (Python):

python

import requests

url = “https://api.nicotine-pouches.org/v1/products”
headers = {
“Authorization”: “Bearer YOUR_API_KEY”
}
response = requests.get(url, headers=headers, params={“limit”: 10, “offset”: 0})
print(response.json())

Example (PHP):

php

$api_key = "YOUR_API_KEY";
$url = "https://api.nicotine-pouches.org/v1/products?limit=10&offset=0";
$headers = array(
"Authorization: Bearer $api_key"
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);$data = json_decode($response, true);
print_r($data);
?>

2. Get Product Details

Retrieve details of a specific product.

URL: /products/{id}

Method: GET

Parameters:

Name Type Description
id int ID of the product to retrieve

Response:

json

{
"status": "success",
"data": {
"id": 1,
"name": "Nicotine Pouch 1",
"brand": "Brand A",
"price": 4.99,
"rating": 4.5,
"description": "Detailed description of the product."
}
}

Example (Python):

python

import requests

product_id = 1
url = f”https://api.nicotine-pouches.org/v1/products/{product_id}
headers = {
“Authorization”: “Bearer YOUR_API_KEY”
}
response = requests.get(url, headers=headers)
print(response.json())

Example (PHP):

php

$api_key = "YOUR_API_KEY";
$product_id = 1;
$url = "https://api.nicotine-pouches.org/v1/products/$product_id";
$headers = array(
"Authorization: Bearer $api_key"
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);$data = json_decode($response, true);
print_r($data);
?>

3. Submit a Review

Submit a review for a product.

URL: /reviews

Method: POST

Parameters:

Name Type Description
product_id int ID of the product being reviewed
user_id int ID of the user submitting the review
rating float Rating given by the user
comment string Review comment

Response:

json

{
"status": "success",
"message": "Review submitted successfully."
}

Example (Python):

python

import requests

url = “https://api.nicotine-pouches.org/v1/reviews”
headers = {
“Authorization”: “Bearer YOUR_API_KEY”,
“Content-Type”: “application/json”
}
data = {
“product_id”: 1,
“user_id”: 123,
“rating”: 4.5,
“comment”: “Great product!”
}
response = requests.post(url, headers=headers, json=data)
print(response.json())

Example (PHP):

php

$api_key = "YOUR_API_KEY";
$url = "https://api.nicotine-pouches.org/v1/reviews";
$headers = array(
"Authorization: Bearer $api_key",
"Content-Type: application/json"
);
$data = json_encode(array(
"product_id" => 1,
"user_id" => 123,
"rating" => 4.5,
"comment" => "Great product!"
));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);$result = json_decode($response, true);
print_r($result);
?>

Error Handling

All error responses follow the format below:

Response:

json

{
"status": "error",
"message": "Description of the error"
}

Example Error Response:

json

{
"status": "error",
"message": "Invalid API key"
}

Conclusion

This documentation provides an overview of how to interact with the Nicotine Pouches API using both Python and PHP. If you have any questions or need further assistance, please contact our support team.