Quick Start
This guide will help you get started with the Alifshop API quickly. You'll learn how to authenticate, make your first API call, and understand the basic concepts needed to integrate with our e-commerce platform.
Before you start
Before you can start making requests to the Alifshop API, you'll need:
- Developer Account - Sign up at developer.alifshop.af
- Basic HTTP Knowledge - Understanding of HTTP methods (GET, POST, PUT, DELETE)
- JSON Understanding - Familiarity with JSON data format
- API Testing Tool - Tools like Postman, curl, or your preferred HTTP client
API Endpoints
The Alifshop API is organized around REST principles and uses standard HTTP methods. All API endpoints are served over HTTPS.
Base URL: https://api.alifshop.af/v1
Regional Endpoints:
- Afghanistan:
https://api.alifshop.af/v1
- Global:
https://api.global.alifshop.com/v1
Before you can make requests to the Alifshop API, you will need to grab your API key from your developer dashboard. You find it under Applications » API Keys.
Get your API key
To authenticate with the Alifshop API, you'll need an API key. Here's how to get one:
1. Create a Developer Account
Visit the Alifshop Developer Portal and create your account:
- Go to the registration page
- Fill in your details (name, email, company)
- Verify your email address
- Complete your developer profile
2. Create an Application
Once logged in, create a new application:
- Go to Applications in your dashboard
- Click Create New Application
- Fill in your application details:
- Application Name: Your app name
- Description: Brief description of your integration
- Type: Choose between Web, Mobile, or Server-to-Server
- Redirect URLs: For OAuth applications (if applicable)
3. Get Your Credentials
After creating your application, you'll receive:
{
"client_id": "your_client_id_here",
"client_secret": "your_client_secret_here",
"api_key": "ak_live_your_api_key_here"
}
API Key Types
- Test Keys - For development and testing (prefix:
ak_test_
) - Live Keys - For production use (prefix:
ak_live_
)
Keep your API credentials secure and never expose them in client-side code or public repositories.
Making your first request
Let's make your first API request to get a list of product categories.
Using cURL
curl -X GET "https://api.alifshop.af/v1/catalog/categories" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json"
Using JavaScript (Node.js)
const axios = require('axios');
const apiKey = 'your_api_key_here';
const baseURL = 'https://api.alifshop.af/v1';
const client = axios.create({
baseURL: baseURL,
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
// Get product categories
async function getCategories() {
try {
const response = await client.get('/catalog/categories');
console.log('Categories:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
getCategories();
Using Python
import requests
api_key = 'your_api_key_here'
base_url = 'https://api.alifshop.af/v1'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
# Get product categories
def get_categories():
try:
response = requests.get(f'{base_url}/catalog/categories', headers=headers)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f'Error: {e}')
return None
categories = get_categories()
print('Categories:', categories)
Expected Response
{
"success": true,
"data": {
"categories": [
{
"id": "cat_1",
"name": "Electronics",
"slug": "electronics",
"description": "Electronic devices and accessories",
"parent_id": null,
"level": 0,
"image_url": "https://cdn.alifshop.af/categories/electronics.jpg",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
{
"id": "cat_2",
"name": "Clothing",
"slug": "clothing",
"description": "Fashion and apparel",
"parent_id": null,
"level": 0,
"image_url": "https://cdn.alifshop.af/categories/clothing.jpg",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"page": 1,
"per_page": 20,
"total": 15,
"pages": 1
}
},
"meta": {
"request_id": "req_123456789",
"timestamp": "2024-01-15T12:00:00Z",
"api_version": "v1"
}
}
Common operations
Now that you've made your first API request, here are some common operations to try:
Get Products
curl -X GET "https://api.alifshop.af/v1/catalog/products" \
-H "Authorization: Bearer your_api_key_here"
Search Products
curl -X GET "https://api.alifshop.af/v1/catalog/products/search?q=laptop&category=electronics" \
-H "Authorization: Bearer your_api_key_here"
Get Product Details
curl -X GET "https://api.alifshop.af/v1/catalog/products/prod_123" \
-H "Authorization: Bearer your_api_key_here"
Create a Cart
curl -X POST "https://api.alifshop.af/v1/cart" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cust_123",
"items": [
{
"product_id": "prod_456",
"variant_id": "var_789",
"quantity": 1
}
]
}'
Add Item to Cart
curl -X POST "https://api.alifshop.af/v1/cart/cart_123/items" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"product_id": "prod_456",
"variant_id": "var_789",
"quantity": 2
}'
Next steps
Great! You're now set up and have made your first request to the Alifshop API. Here are some recommended next steps:
Explore Core Modules
Learn about the main modules of the Alifshop API:
- Catalog - Product management, categories, and brands
- Cart - Shopping cart and wishlist functionality
- Orders - Order processing and fulfillment
- Marketing - Campaigns and notifications
Environment Setup
For production applications, consider:
- Rate Limiting - Implement proper rate limiting and retry logic
- Error Handling - Robust error handling for API failures
- Caching - Cache frequently accessed data like categories
- Webhooks - Set up webhooks for real-time updates
- Monitoring - Monitor API usage and performance
Advanced Features
- Pagination - Learn how to handle large datasets efficiently
- Filtering - Use advanced filtering options for better performance
- Webhooks - Set up real-time notifications for important events
- Batch Operations - Perform bulk operations for better efficiency
Resources
- Authentication Guide - Detailed authentication methods
- API Reference - Complete API endpoint documentation
- Architecture Overview - Understanding the system architecture
Support
Need help? Here are ways to get support:
- Documentation - Search our comprehensive documentation
- Developer Forum - Join our developer community
- Support Tickets - Create a support ticket for technical issues
- Status Page - Check API status and uptime
Remember to use test API keys during development and switch to live keys only when you're ready for production.