MagicUI API Documentation

MagicUI API provides RESTful API services for your WordPress and WooCommerce-based e-commerce application. It offers secure access through JWT (JSON Web Token) based authentication system.

Base URL

https://your-domain.com/wp-json/

Authentication

The API uses JWT (JSON Web Token) based authentication. Most endpoints require a valid JWT token.

How to Get a Token?

Use the /jwt-auth/v1/token endpoint to obtain a token. After receiving the token, you need to send it in the Authorization header for every request to protected endpoints.

Authorization: Bearer YOUR_JWT_TOKEN

🔐 Authentication Endpoints

1. Generate Token (Login)

User login to obtain JWT token.

Endpoint: POST /jwt-auth/v1/token

Authentication: Not required

Request Body:

{
  "username": "[email protected]",
  "password": "your_password"
}

Success Response (200):

Error Response (401):

Notes:

  • Token validity is 7 days (604800 seconds)

  • Login uses email address

  • Token is used for all protected endpoints


2. Token Validation

Validates the current token.

Endpoint: POST /jwt-auth/v1/token/validate

Authentication: Bearer Token

Headers:

Success Response (200):

Error Response (401):


3. Token Refresh

Refreshes the current token to get a new one.

Endpoint: POST /jwt-auth/v1/token/refresh

Authentication: Bearer Token

Headers:

Success Response (200):


👤 User Registration

Register New User

Creates a new user account and automatically logs in.

Endpoint: POST /magicui/v1/register

Authentication: Copy the API Key from the MagicUI Plugin API Endpoint and use it to send a POST request to the register endpoint.

Request Body:

Success Response (200):

Error Response (400):

Validation Rules:

  • Email must be in valid email format

  • Username must be unique

  • Password must be at least 6 characters

  • Email must be unique


🛍️ Product Endpoints

1. Product List

Lists WooCommerce products. Supports filtering, searching, and pagination.

Endpoint: GET /magicui/v1/products

Authentication: Not required

Query Parameters:

Parameter
Type
Description
Default

page

integer

Page number

1

per_page

integer

Products per page

20

search

string

Search in product name

-

category

integer

Filter by category ID

-

orderby

string

Sort criteria (date, title, price, popularity, rating)

date

order

string

Sort direction (ASC, DESC)

DESC

on_sale

boolean

Sale products only

false

featured

boolean

Featured products only

false

Example Request:

Success Response (200):


2. Product Details

Retrieves detailed information about a specific product.

Endpoint: GET /magicui/v1/products/{id}

Authentication: Not required

Path Parameters:

Parameter
Type
Description

id

integer

Product ID

Success Response (200):


3. Product Variations

Lists variations of variable products.

Endpoint: GET /magicui/v1/products/{id}/variations

Authentication: Not required

Success Response (200):


4. Categories

Lists product categories.

Endpoint: GET /magicui/v1/categories

Authentication: Not required

Query Parameters:

Parameter
Type
Description
Default

page

integer

Page number

1

per_page

integer

Categories per page

100

parent

integer

Parent category ID

-

hide_empty

boolean

Hide empty categories

true

orderby

string

Sort criteria

name

order

string

Sort direction

ASC

Success Response (200):


5. Product Reviews

Lists reviews for a product.

Endpoint: GET /magicui/v1/products/{id}/reviews

Authentication: Not required

Success Response (200):


6. Submit Review

Adds a new review to a product.

Endpoint: POST /magicui/v1/products/{id}/reviews

Authentication: Bearer Token required

Request Body:

Success Response (200):


🛒 Order Endpoints

1. Order List

Lists user's orders.

Endpoint: GET /magicui/v1/orders

Authentication: Bearer Token required

Success Response (200):


2. Order Details

Retrieves detailed information about a specific order.

Endpoint: GET /magicui/v1/orders/{id}

Authentication: Bearer Token required

Response: Same format as order list, returns single order.


3. Create Order

Creates a new order.

Endpoint: POST /magicui/v1/orders

Authentication: Bearer Token required

Request Body:

Success Response (200):

Features:

  • Automatic duplicate order prevention (5 minutes)

  • Payment gateway integration

  • Automatic billing and shipping address creation

  • Stock control

  • Coupon application


4. Cancel Order

Cancels an order.

Endpoint: PUT /magicui/v1/orders/{id}/cancel

Authentication: Bearer Token required

Success Response (200):

Notes:

  • Only orders with status "pending", "on-hold", "processing" can be cancelled

  • Orders with status "completed", "cancelled", "refunded" cannot be cancelled


5. Refund Order

Refunds a completed order.

Endpoint: POST /magicui/v1/orders/{id}/refund

Authentication: Bearer Token required

Success Response (200):

Notes:

  • Only orders with "completed" status can be refunded

  • Full refund is processed

  • Return period is configured in settings (default 14 days)


👤 User Endpoints

1. Update Profile

Updates user profile information.

Endpoint: POST /magicui/v1/user/update

Authentication: Bearer Token required

Request Body:

Success Response (200):

Notes:

  • For billing address, account_type can be "individual" or "corporate"

  • Individual accounts require identity_number (National ID)

  • Corporate accounts require tax_id_number (Tax ID) and company_name


2. Get User Info

Retrieves detailed information about the current user.

Endpoint: GET /magicui/v1/user/me

Authentication: Bearer Token required

Success Response (200):


3. Change Password

Changes user's password.

Endpoint: POST /magicui/v1/user/password

Authentication: Bearer Token required

Request Body:

Success Response (200):

Notes:

  • Password must be at least 6 characters

  • Current token remains valid after password change


4. Reset Password

Password reset via email.

Endpoint: POST /magicui/v1/user/reset_password

Authentication: Not required

Request Body:

Success Response (200):

Notes:

  • Generates a random 8-character password

  • New password is sent to user's email address


5. Upload Avatar

Uploads user profile picture.

Endpoint: POST /magicui/v1/user/avatar

Authentication: Bearer Token required

Content-Type: multipart/form-data

Form Data:

Success Response (200):

Supported Formats:

  • JPEG/JPG

  • PNG

  • GIF

  • WebP

Maximum File Size: 5MB


6. Get Avatar

Retrieves user's current avatar information.

Endpoint: GET /magicui/v1/user/avatar

Authentication: Bearer Token required

Success Response (200):


7. Favorites

Get Favorites List

Endpoint: GET /magicui/v1/user/favorites

Authentication: Bearer Token required

Success Response (200):

Add/Remove Favorite

Endpoint: POST /magicui/v1/user/favorites

Authentication: Bearer Token required

Request Body:

Success Response (200):


8. Update Device ID (Push Notifications)

Registers OneSignal device ID.

Endpoint: POST /magicui/v1/user/device-id

Authentication: Bearer Token required

Request Body:

Success Response (200):


⚙️ Configuration and Other Endpoints

1. App Configuration

Retrieves app settings and configuration.

Endpoint: GET /magicui/v1/config

Authentication: API Key (Header: X-API-Key)

Success Response (200):


2. Home Page Data

Retrieves banners and categories for home page.

Endpoint: GET /magicui/v1/home

Authentication: Not required

Success Response (200):


3. Payment Gateways

Lists active payment methods.

Endpoint: GET /magicui/v1/payment-gateways

Authentication: Bearer Token required

Success Response (200):


4. Shipping Zones

Lists WooCommerce shipping zones.

Endpoint: GET /magicui/v1/shipping-zones

Authentication: Bearer Token required

Success Response (200):


5. Shipping Methods

Lists shipping methods for a specific zone.

Endpoint: GET /magicui/v1/shipping-zones/{zone_id}/methods

Authentication: Bearer Token required

Success Response (200):


6. Validate Coupon

Validates coupon code.

Endpoint: GET /magicui/v1/validate-coupon?code=SAVE20

Authentication: Bearer Token required

Query Parameters:

Parameter
Type
Description

code

string

Coupon code

Success Response (200):

Discount Types:

  • percent - Percentage discount

  • fixed_cart - Fixed amount for cart

  • fixed_product - Fixed amount for product


7. Locations (Countries and States)

Lists all countries and states.

Endpoint: GET /magicui/v1/locations

Authentication: Not required

Success Response (200):


8. Privacy Policy

Retrieves app privacy policy.

Endpoint: GET /magicui/v1/privacy

Authentication: Not required

Success Response (200):


9. Terms of Use

Retrieves app terms of use.

Endpoint: GET /magicui/v1/terms

Authentication: Not required

Success Response (200):


10. Health Check

Returns API status and version information.

Endpoint: GET /magicui/v1/health

Authentication: Not required

Success Response (200):


🔒 Security

JWT Token Security

  1. Token Storage: Store token securely (iOS Keychain, Android KeyStore)

  2. HTTPS: Make all API requests over HTTPS

  3. Token Refresh: Refresh token before expiration

  4. Token Revocation: Delete token on logout

Error Handling

All error responses follow this format:

HTTP Status Codes

Code
Description

200

Success

201

Created

400

Bad Request

401

Unauthorized (Invalid/missing token)

403

Forbidden (No permission)

404

Not Found

500

Server Error


📱 Special Features

1. Push Notifications

  • OneSignal integration

  • Automatic notifications on order status changes

  • Custom notification sending (from Admin panel)

2. Return Management

  • Automatic return eligibility check

  • Configurable return period

  • Calculation based on order completion date

3. Duplicate Order Prevention

  • 5-minute temporary cache

  • Hash-based order verification

  • Automatic existing order return

4. Multi-language Support

Supported languages:

  • Turkish (tr)

  • English (en)

  • German (de)

  • Russian (ru)

  • Portuguese (pt)

  • Arabic (ar)

  • French (fr)

  • Spanish (es)

  • Hindi (hi)

  • Chinese (zh)


🎯 Best Practices

1. Token Management

2. Error Handling

3. Pagination


📞 Support

For questions:


Note: This API is continuously being developed. Check the documentation regularly for updates.

Last updated

Was this helpful?