ronknight / alibaba-open-api

🌐A Python-based integration for the Alibaba Open API, providing authentication, token management, and product listing functionalities.

Repository from Github https://github.comronknight/alibaba-open-apiRepository from Github https://github.comronknight/alibaba-open-api

A Python-based integration for the Alibaba Open API, providing authentication, token management, and product listing functionalities.

Requirements β€’ Usage β€’ API Endpoints β€’ Scripts β€’ Disclaimer β€’ Architecture


πŸ“‹ Requirements

To run this project, you need:

  • Python 3.7+
  • pip (Python package installer)

Required Python packages:

anyio==4.4.0
argon2-cffi==23.1.0
requests==2.32.3
python-dotenv==1.0.1

A full list of dependencies can be found in the requirements.txt file.

πŸš€ Usage

  1. Clone the repository:

    git clone https://github.com/ronknight/alibaba-open-api.git
    cd alibaba-open-api
    
  2. Install the required packages:

    pip install -r requirements.txt
    
  3. Set up your .env file with the necessary credentials:

    APP_KEY=your_app_key
    APP_SECRET=your_app_secret
    REDIRECT_URI=your_redirect_uri
    
  4. Run the scripts in the following order:

    python 1initiate.py
    python 2createtoken.py
    python 3refreshtoken.py
    python productlist.py
    

πŸ“‘ API Endpoints

Authentication Endpoints

Endpoint Description
/auth/token/create Create new access and refresh tokens
/auth/token/refresh Refresh existing access token

Product Endpoints

Endpoint Description
/icbu/product/list Get list of products
/icbu/product/category/get Get product category details
/icbu/product/schema/level/get Get product schema level

Category Endpoints

Endpoint Description
/alibaba/icbu/category/id/mapping Get category ID mapping
/icbu/product/category/get Get category information

πŸ“œ Scripts

  1. 1initiate.py: Initiates the OAuth process and obtains the authorization code.
  2. 2createtoken.py: Creates access and refresh tokens using the authorization code.
  3. 3refreshtoken.py: Refreshes the access token using the refresh token.
  4. productlist.py: Retrieves the product list using the access token.
  5. product_category_get.py: Gets product category information.
  6. product_schema_level_get.py: Gets product schema level information.

⚠️ Disclaimer

This project is for educational purposes only. Ensure you comply with Alibaba's API usage terms and conditions.

πŸ“Š Architecture

Authentication Flow

sequenceDiagram
    participant Client
    participant Auth
    participant API
    Client->>Auth: 1. Request Authorization Code
    Auth-->>Client: 2. Return Auth Code
    Client->>API: 3. Exchange Auth Code for Tokens
    API-->>Client: 4. Return Access & Refresh Tokens
    Client->>API: 5. API Requests with Access Token
    API-->>Client: 6. API Response
Loading

Product Data Flow

flowchart LR
    A[Start] --> B{Has Access Token?}
    B -- No --> C[Request Token]
    B -- Yes --> D[Product API]
    C --> D
    D --> E[Get Categories]
    D --> F[Get Products]
    D --> G[Get Schema]
    E & F & G --> H[Process Data]
    H --> I[End]
Loading

About

🌐A Python-based integration for the Alibaba Open API, providing authentication, token management, and product listing functionalities.

License:MIT License


Languages

Language:Python 100.0%