### Basic Usage Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md Demonstrates how to initialize the client, make a search request, and process the response. ```APIDOC ## Basic Usage ### Initialize Client ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_api_token") ``` ### Make Request ```python response = client.douyin.search_video_v4(keyword="python") ``` ### Process Response ```python if response.success: print(f"Found {len(response.data.get('items', []))} videos") else: print(f"Error: {response.code} - {response.message}") ``` ### Cleanup ```python client.close() ``` ``` -------------------------------- ### Install Just One API Python SDK Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Install the SDK using pip. This is the first step before using any of the SDK's functionalities. ```bash pip install justoneapi ``` -------------------------------- ### Environment Setup Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Instructions for setting up the JustOneAPI client using environment variables or a configuration file. ```APIDOC ## Environment Setup ### Description Configure your API token either through environment variables or a JSON configuration file for secure and flexible setup. ### Using Environment Variable ```python import os from justoneapi import JustOneAPIClient token = os.getenv("JUSTONEAPI_TOKEN") client = JustOneAPIClient(token=token) ``` ### Using Config File ```python import json from justoneapi import JustOneAPIClient with open("config.json") as f: config = json.load(f) client = JustOneAPIClient(token=config["token"]) ``` ``` -------------------------------- ### HTTP Request Format Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Illustrates the structure of a typical GET request with query parameters. ```http GET /api/douyin/search-video/v4?token=abc123&keyword=test&page=1&sortType=_0 ``` -------------------------------- ### Parameter Flow Example in Python Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Illustrates how client-side parameters are transformed into a transport-level GET request with cleaned parameters, including the addition of an authentication token. ```python # Client call response = client.douyin.search_video_v4( keyword="test", sort_type="_1", page=2 ) # Becomes Transport.get( "/api/douyin/search-video/v4", { "keyword": "test", "sortType": "_1", "page": 2 } ) # Parameters cleaned { "keyword": "test", "sortType": "_1", "page": 2, "token": "your_token" } # HTTP request GET /api/douyin/search-video/v4?keyword=test&sortType=_1&page=2&token=your_token ``` -------------------------------- ### Douyin Resource: Search Video Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md An example of how to use the `search_video_v4` method from the Douyin resource to search for videos. ```APIDOC ## Usage Examples - Douyin Resource ### Search Video This example shows how to search for videos using the `search_video_v4` method. #### Method Signature ```python def search_video_v4( self, *, keyword: str, sort_type: str | None = "_0", publish_time: str | None = "_0", ... ) -> ApiResponse[Any] ``` #### Parameters | Parameter | Type | Default | Description | |---|---|---|---| | keyword | str | — | Search keyword. Required. | | sort_type | str | "_0" | Sorting criteria... | #### Usage Example ```python response = client.douyin.search_video_v4(keyword="test") if response.success: videos = response.data.get('items', []) ``` ``` -------------------------------- ### Parameter Processing Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Demonstrates how parameters, including booleans, are processed before being sent in a request. ```python response = client.weibo.search_all_v2( q="test", start_day="2024-01-01", start_hour=0, end_day="2024-01-31", end_hour=23, hot_sort=True, # Sent as "true" contains="ALL", page=1 ) # Request parameters: # q=test&startDay=2024-01-01&startHour=0&endDay=2024-01-31 # &endHour=23&hotSort=true&contains=ALL&page=1&token=... ``` -------------------------------- ### Development Setup Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Configure the client for development with a longer timeout (120 seconds) and enable error feedback by setting raise_on_business_error to True. ```python from justoneapi import JustOneAPIClient # Development with longer timeout and error feedback client = JustOneAPIClient( token="dev_token_xxxxx", timeout=120, raise_on_business_error=True ) ``` -------------------------------- ### Production Setup Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Configure the client for production, reading the token and base URL from environment variables. Sets a timeout of 30 seconds and disables business error exceptions. ```python from justoneapi import JustOneAPIClient import os # Production with secure token handling token = os.getenv("JUSTONEAPI_TOKEN") base_url = os.getenv("JUSTONEAPI_BASE_URL", "https://api.justoneapi.com") client = JustOneAPIClient( token=token, base_url=base_url, timeout=30, raise_on_business_error=False ) ``` -------------------------------- ### Request Headers Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Shows the standard headers included in API requests, including the SDK version for debugging. ```http Host: api.justoneapi.com User-Agent: httpx/[version] Accept: */* Accept-Encoding: gzip, deflate JUSTONEAPI_PYTHON_SKD_VERSION: 3.0.14 ``` -------------------------------- ### Example Usage within Context Manager Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/client.md Demonstrates how to use the client within a 'with' statement, accessing API data and ensuring the client is automatically closed. ```python with JustOneAPIClient(token="your_api_token") as client: response = client.douyin.search_video_v4(keyword="test") print(response.success) print(response.data) # Client is automatically closed here ``` -------------------------------- ### Error Handling Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md Illustrates how to handle business logic errors and transport errors using try-except blocks. ```APIDOC ## Error Handling ### Initialize Client with Error Raising ```python from justoneapi import BusinessError, TransportError client = JustOneAPIClient(token="your_token", raise_on_business_error=True) ``` ### Handle Exceptions ```python try: response = client.douyin.search_video_v4(keyword="test") except BusinessError as e: print(f"API error: {e.response.code}") except TransportError as e: print(f"Network error: {e}") ``` ``` -------------------------------- ### Querying LLM Services Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/resources-overview.md Access AI services through the 'llm' resource. This example shows how to query a Doubao AI model. ```python # Query AI services response = client.llm.doubao_answer_v1(keyword="What is Python?") ``` -------------------------------- ### Test JustOneAPI Client Search Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md This snippet demonstrates how to set up a test client and perform a video search using the SDK. Ensure you have pytest installed. ```python import pytest from justoneapi import JustOneAPIClient, BusinessError @pytest.fixture def client(): return JustOneAPIClient(token="test_token") def test_search(client): response = client.douyin.search_video_v4(keyword="test") assert response is not None assert hasattr(response, 'success') ``` -------------------------------- ### Douyin Video Search Example Source: https://github.com/justoneapi/justoneapi-python/blob/main/README.en.md Demonstrates how to perform a Douyin video search using the `search_video_v4` method of the `douyin` client. It shows how to initialize the client and process the response. ```APIDOC ## Douyin Video Search ### Description Performs a search for Douyin videos based on a keyword. ### Method `client.douyin.search_video_v4(keyword: str)` ### Parameters #### Path Parameters None #### Query Parameters - **keyword** (str) - Required - The keyword to search for. ### Request Example ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_token") response = client.douyin.search_video_v4(keyword="deepseek") ``` ### Response #### Success Response (200) - **success** (bool) - True if the request was successful (code == 0). - **code** (Any) - The business code returned by the API. - **message** (str) - A message from the server. - **data** (Any) - The actual payload of the response. - **raw_json** (dict) - The complete response payload before SDK normalization. #### Response Example ```json { "success": true, "code": 0, "message": "Success", "data": { ... }, "raw_json": { ... } } ``` ``` -------------------------------- ### Configuration Options Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md Details on all configuration options, environment setup, connection management, and thread safety for the Just One API Python SDK. ```APIDOC ## Configuration ### Description This section covers how to configure the Just One API Python SDK, including setting up your API key, managing connection timeouts, and ensuring thread safety. ### Environment Variables The SDK can be configured using environment variables: - `JUSTONEAPI_API_KEY`: Your Just One API key. - `JUSTONEAPI_BASE_URL`: The base URL for the API (if not using the default). ### Client Initialization Options When initializing `JustOneAPIClient`, you can pass configuration options directly: ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient( api_key="YOUR_API_KEY", base_url="https://api.example.com", timeout=60.0, retries=5 ) ``` ### Thread Safety The `JustOneAPIClient` is designed to be thread-safe. You can share a single client instance across multiple threads. ### Connection Management The SDK manages HTTP connections internally. For advanced control, refer to the 'Transport & Auth' documentation. ``` -------------------------------- ### LLM Services Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/resources-overview.md Access AI services through the `llm` resource. This example shows how to query for an answer using the `doubao_answer_v1` method. ```APIDOC ## LLM Services The `llm` resource provides access to AI services: ```python # Query AI services response = client.llm.doubao_answer_v1(keyword="What is Python?") ``` ``` -------------------------------- ### Get User Content by Platform Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Retrieve a list of content (videos, posts, notes) created by a user on various platforms. Different platforms require specific user identifiers. ```python # Douyin videos client.douyin.get_user_video_list_v3(sec_uid="user_id") ``` ```python # Instagram posts client.instagram.get_user_posts_v1(username="username") ``` ```python # Xiaohongshu notes client.xiaohongshu.get_user_note_list_v1(user_id="user_id") ``` ```python # Weibo posts client.weibo.get_user_post_v1(uid="uid") ``` -------------------------------- ### Search Douyin Videos Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md Example of searching for Douyin videos using the `search_video_v4` method. This method requires a keyword and supports optional parameters for sorting and publication time. ```python response = client.douyin.search_video_v4(keyword="test") if response.success: videos = response.data.get('items', []) ``` -------------------------------- ### Batch Operations Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/client.md Provides an example of how to perform batch operations by iterating through a list of identifiers and making individual API calls for each. It also shows the importance of closing the client connection. ```APIDOC ## Batch Operations This example demonstrates how to perform operations on multiple items by iterating through a list and making individual API calls. ### Method Signature `client.douyin.get_user_detail_v3(sec_uid: str)` ### Parameters - **sec_uid** (str) - Required - The secure user ID for which to retrieve details. ### Request Example ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_api_token") user_ids = ["user1", "user2", "user3"] results = [] for user_id in user_ids: response = client.douyin.get_user_detail_v3(sec_uid=user_id) if response.success: results.append(response.data) # Cleanup client.close() ``` ### Response - **success** (bool) - Indicates if the API call was successful for a given user ID. - **data** (dict) - The user detail data if successful. - **code** (int) - Error code if `success` is false. - **message** (str) - Error message if `success` is false. ``` -------------------------------- ### Get Item Detail v2 - TaobaoResource Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Retrieves product details (v2) from Taobao/Tmall. Note that direct API calls may return setup instructions if not configured in the dashboard. ```python response = client.taobao.get_item_detail_v2(item_id="123456789") if response.success: product = response.data # Check if data is available or setup instructions if isinstance(product, dict) and 'title' in product: print(f"Product: {product['title']}") else: print("Setup required in dashboard") ``` -------------------------------- ### Set Up JustOneAPI Client from Environment or Config Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Initialize the client by loading the API token from an environment variable named `JUSTONEAPI_TOKEN` or from a JSON configuration file. ```python import os from justoneapi import JustOneAPIClient # From environment variable token = os.getenv("JUSTONEAPI_TOKEN") client = JustOneAPIClient(token=token) # From config file import json with open("config.json") as f: config = json.load(f) client = JustOneAPIClient(token=config["token"]) ``` -------------------------------- ### Quick Start: Make an API Call Source: https://github.com/justoneapi/justoneapi-python/blob/main/README.en.md Initialize the client with your API token and make a sample call to the Douyin video search API. Check the response fields for success status, business code, message, and data. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_token") # Example: Douyin video search response = client.douyin.search_video_v4(keyword="deepseek") print(response.success) # True only when code == 0 print(response.code) # Business code returned by the API print(response.message) # Server message print(response.data) # Actual payload ``` -------------------------------- ### get_item_detail_v2 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Get product details (v2). This version is available through the dashboard task management page. Note: Direct API calls return setup instructions instead of product data. Configure in dashboard first. ```APIDOC ## get_item_detail_v2 ### Description Get product details (v2). This version is available through the dashboard task management page. ### Method GET (assumed) ### Endpoint /taobao/item/detail/v2 ### Parameters #### Query Parameters - **item_id** (str) - Required - Unique product identifier (item ID). ### Response #### Success Response (200) - **data** (Any) - Contains product details or setup instructions if not configured. ### Request Example ```python response = client.taobao.get_item_detail_v2(item_id="123456789") ``` ### Response Example ```json { "success": true, "data": { "title": "Example Product Title", "price": "199.00" } } ``` **Note:** If data is not available, the response might contain setup instructions. ``` -------------------------------- ### Basic Client Usage Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md Demonstrates how to create a client instance, make a request to the Douyin search video endpoint, and handle the response. Remember to replace 'your_api_token' with your actual API token. The client should be closed after use. ```python from justoneapi import JustOneAPIClient # Create client client = JustOneAPIClient(token="your_api_token") # Make request response = client.douyin.search_video_v4(keyword="python") # Check result if response.success: print(response.data) else: print(f"Error: {response.code}") # Cleanup client.close() ``` -------------------------------- ### Testing Setup with Exceptions Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Configure the client for testing with a 60-second timeout and enable exceptions for business errors to ensure clearer test failures. Includes a try-except block to catch and print business errors. ```python from justoneapi import JustOneAPIClient, BusinessError # Testing with exceptions enabled for clearer test failures client = JustOneAPIClient( token="test_token", timeout=60, raise_on_business_error=True ) try: response = client.douyin.search_video_v4(keyword="test") except BusinessError as e: print(f"Test failed: {e.response.code}") ``` -------------------------------- ### get_item_detail_v9 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Get product details from Taobao/Tmall (v9). Returns product details. ```APIDOC ## get_item_detail_v9 ### Description Get product details from Taobao/Tmall (v9). ### Method GET (assumed) ### Endpoint /taobao/item/detail/v9 ### Parameters #### Query Parameters - **item_id** (str) - Required - Unique product identifier (item ID). ### Response #### Success Response (200) - **data** (Any) - Contains product details. ### Request Example ```python response = client.taobao.get_item_detail_v9(item_id="123456789") ``` ### Response Example ```json { "success": true, "data": { "title": "Example Product Title", "price": "199.00" } } ``` ``` -------------------------------- ### get_item_detail_v5 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Get product details from Taobao/Tmall (v5). Returns product details. ```APIDOC ## get_item_detail_v5 ### Description Get product details from Taobao/Tmall (v5). ### Method GET (assumed) ### Endpoint /taobao/item/detail/v5 ### Parameters #### Query Parameters - **item_id** (str) - Required - Unique product identifier (item ID). ### Response #### Success Response (200) - **data** (Any) - Contains product details. ### Request Example ```python response = client.taobao.get_item_detail_v5(item_id="123456789") ``` ### Response Example ```json { "success": true, "data": { "title": "Example Product Title", "price": "199.00" } } ``` ``` -------------------------------- ### Authentication and Client Initialization Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md Demonstrates how to obtain an API token and initialize the JustOneAPIClient. ```APIDOC ## Authentication API token obtained from https://dashboard.justoneapi.com ```python import os from justoneapi import JustOneAPIClient token = os.getenv("JUSTONEAPI_TOKEN") client = JustOneAPIClient(token=token) ``` **Full guide:** [Configuration.md](configuration.md) or [Transport & Auth.md](transport-and-auth.md) ``` -------------------------------- ### Get Note Comments Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Fetches comments associated with a specific note, with support for pagination. ```APIDOC ## get_note_comments_v1 ### Description Get comments on a specific note. ### Method GET (assumed, based on function name and parameters) ### Endpoint /xiaohongshu/notes/{note_id}/comments (assumed, based on function name and parameters) ### Parameters #### Path Parameters - **note_id** (str) - Required - Note's unique ID. #### Query Parameters - **last_cursor** (str) - Optional - Pagination cursor. ### Response #### Success Response (200) - **ApiResponse[Any]** - Containing comment list with authors and engagement. ### Request Example ```python client.xiaohongshu.get_note_comments_v1(note_id='your_note_id', last_cursor='your_cursor') ``` ### Response Example ```json { "success": true, "data": { "comments": [ ... ], "last_cursor": "next_cursor" } } ``` ``` -------------------------------- ### Initialize Client with Configuration File Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Initialize the client by reading API token, base URL, and timeout from a JSON configuration file. Provides default values for base_url and timeout if not specified in the file. ```python import json from justoneapi import JustOneAPIClient # Read from config file with open("config.json") as f: config = json.load(f) client = JustOneAPIClient( token=config["api_token"], base_url=config.get("base_url", "https://api.justoneapi.com"), timeout=config.get("timeout", 60), ) ``` -------------------------------- ### get_weibo_detail_v1 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/weibo-resource.md Get detailed information about a specific Weibo post using its unique ID. ```APIDOC ## get_weibo_detail_v1 ### Description Get detailed information about a specific Weibo post using its unique ID. ### Method POST ### Endpoint /weibo/get_weibo_detail_v1 ### Parameters #### Query Parameters - **id_** (str) - Required - Weibo post ID. ### Response #### Success Response (200) - **id** (str) - Weibo post ID. - **created_at** (str) - Creation timestamp. - **text** (str) - Post content. - **user** (object) - Author information. - **reposts_count** (int) - Number of reposts. - **comments_count** (int) - Number of comments. - **attitudes_count** (int) - Number of likes. #### Response Example ```json { "success": true, "data": { "id": "4567890123456789", "created_at": "Tue May 31 10:00:00 +0800 2024", "text": "This is a sample Weibo post.", "user": { "id": 123456789, "screen_name": "example_user", "name": "Example User Name", "verified": true }, "reposts_count": 15, "comments_count": 8, "attitudes_count": 30 } } ``` ``` -------------------------------- ### Initialize and Use Client with Context Manager Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Recommended for automatic cleanup. Initializes a client and ensures it is closed properly after use, even if errors occur. ```python from justoneapi import JustOneAPIClient # Automatic cleanup with JustOneAPIClient(token="your_token") as client: response = client.douyin.search_video_v4(keyword="test") print(response.data) # Client closed automatically ``` -------------------------------- ### Get Note Detail Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Retrieves detailed information for a specific note using its unique ID. ```APIDOC ## get_note_detail_v1 ### Description Get detailed information about a specific note. ### Method GET (assumed, based on function name and parameters) ### Endpoint /xiaohongshu/notes/{note_id} (assumed, based on function name and parameters) ### Parameters #### Path Parameters - **note_id** (str) - Required - Note's unique ID. ### Response #### Success Response (200) - **ApiResponse[Any]** - Containing full note content, author details, and engagement metrics. ### Request Example ```python client.xiaohongshu.get_note_detail_v1(note_id='your_note_id') ``` ### Response Example ```json { "success": true, "data": { "note_content": "...", "author_details": { ... }, "engagement_metrics": { ... } } } ``` ``` -------------------------------- ### Configuration.md - Constructor Options Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md Details all available options for configuring the JustOneAPIClient during initialization. ```APIDOC ## Configuration ### Description This section details the various options available when initializing the `JustOneAPIClient`, allowing for customization of API interaction, authentication, and connection behavior. ### Constructor Options - **api_key** (str, optional): Your unique API key for authentication. If not provided, the SDK will attempt to use the `JUSTONEAPI_API_KEY` environment variable. - **endpoint** (str, optional): The base URL for the Just One API. Defaults to `https://api.justoneapi.com`. Useful for specifying custom or private endpoints. - **timeout** (float, optional): The request timeout in seconds. Defaults to 10.0. - **max_retries** (int, optional): The maximum number of times to retry a failed request. Defaults to 3. - **retry_delay** (float, optional): The delay in seconds between retries. Defaults to 1.0. - **proxies** (dict, optional): A dictionary mapping protocol names to proxy URLs (e.g., `{'http': 'http://localhost:8080', 'https': 'http://localhost:8080'}`). - **verify_ssl** (bool, optional): Whether to verify SSL certificates. Defaults to `True`. - **connection_pool_size** (int, optional): The size of the connection pool for HTTP requests. Defaults to 5. ``` -------------------------------- ### Get User Profiles Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md Retrieves user profile information from all supported social media platforms. ```APIDOC ## GET /user/profile ### Description Retrieves the profile information for a specified user across social media platforms. ### Method GET ### Endpoint https://api.justoneapi.com/user/profile ### Parameters #### Query Parameters - **username** (string) - Required - The username of the profile to retrieve. - **platform** (string) - Optional - The specific platform to get the profile from. ### Request Example ```json { "username": "example_user", "platform": "Instagram" } ``` ### Response #### Success Response (200) - **code** (integer) - Indicates the success of the operation. - **message** (string) - A message describing the result. - **data** (object) - Contains the user profile details. - **requestId** (string) - Unique identifier for the request. - **recordTime** (string) - Timestamp of when the record was created. #### Response Example ```json { "code": 0, "message": "success", "data": { ... }, "requestId": "...", "recordTime": "..." } ``` ``` -------------------------------- ### Get Douyin Video Comments Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/douyin-resource.md Retrieves comments for a specific Douyin video. Supports pagination. ```python response = client.douyin.get_video_comment_v1(aweme_id="7123456789") if response.success: for comment in response.data.get('comments', []): print(f"{comment['author']['nickname']}: {comment['text']}") print(f" Likes: {comment['like_count']}") ``` -------------------------------- ### Basic Client Usage Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/INDEX.md Instantiate the client with an API token, make a request to a specific resource (e.g., douyin search), and process the response. Remember to close the client when done. ```python from justoneapi import JustOneAPIClient # Create client client = JustOneAPIClient(token="your_api_token") # Make request response = client.douyin.search_video_v4(keyword="python") # Check result if response.success: print(f"Found {len(response.data.get('items', []))}" videos) else: print(f"Error: {response.code} - {response.message}") # Cleanup client.close() ``` -------------------------------- ### Initialize JustOneAPI Client Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md Import the client and initialize it with your API token. The token can be set as an environment variable. ```python import os from justoneapi import JustOneAPIClient token = os.getenv("JUSTONEAPI_TOKEN") client = JustOneAPIClient(token=token) ``` -------------------------------- ### Common Parameter Types - Sort Order Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Examples of how to specify sort order for Douyin API requests. ```APIDOC ## Common Parameter Types - Sort Order ### Description Specify the desired sorting criteria for Douyin API requests. ### Douyin Sort Types - `"_0"`: General sorting. - `"_1"`: Sort by most likes. - `"_2"`: Sort by newest. ### Example Usage ```python # For Douyin sort_type="_1" # Sort by most likes response = client.douyin.some_method(sort_type=sort_type) ``` ``` -------------------------------- ### Initialize and Use Client with Manual Cleanup Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Manually initializes a client and requires explicit closing using a try-finally block to ensure resources are released. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_token") try: response = client.douyin.search_video_v4(keyword="test") print(response.data) finally: client.close() ``` -------------------------------- ### Get Comments Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Fetch comments for videos, posts, or notes from platforms like Douyin, Instagram, and Xiaohongshu. ```APIDOC ## Get Comments ### Description Retrieves comments associated with a specific piece of content (video, post, note) on supported platforms. ### Method client.get_content_comments_vX ### Parameters - **platform** (string) - Required - The platform where the content is hosted (e.g., 'DOUYIN', 'INSTAGRAM', 'XIAOHONGSHU'). - **content_id** (string) - Required - The unique identifier of the content (e.g., 'aweme_id' for Douyin videos, 'code' for Instagram posts, 'note_id' for Xiaohongshu notes). ### Example ```python # Get Douyin video comments client.douyin.get_video_comment_v1(aweme_id="video_id") # Get Instagram post comments client.instagram.get_post_comments_v1(code="post_code") # Get Xiaohongshu note comments client.xiaohongshu.get_note_comments_v1(note_id="note_id") ``` ``` -------------------------------- ### Get Douyin Video Sub-Comments Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/douyin-resource.md Fetches replies to a specific comment on a Douyin video. Supports pagination. ```python response = client.douyin.get_video_sub_comment_v1(comment_id="comment123") if response.success: for reply in response.data.get('replies', []): print(f"{reply['author']['nickname']}: {reply['text']}") ``` -------------------------------- ### Initialize JustOneAPIClient Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Configure the client with your API token, base URL, request timeout, and error handling behavior. The token is required for authentication. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient( token="your_api_token", base_url="https://api.justoneapi.com", timeout=60, raise_on_business_error=False ) ``` -------------------------------- ### Initialize JustOneAPIClient Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/client.md Instantiate the client with basic or custom configurations. Supports optional base URL, timeout, and error handling settings. Raises ValueError if the token is empty. ```python from justoneapi import JustOneAPIClient # Basic initialization client = JustOneAPIClient(token="your_api_token") # With custom configuration client = JustOneAPIClient( token="your_api_token", base_url="https://api.justoneapi.com", timeout=30, raise_on_business_error=True ) ``` -------------------------------- ### Initialize Client with Environment Token Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Initialize the client using an API token read from the JUSTONEAPI_TOKEN environment variable. Raises a ValueError if the environment variable is not set. ```python import os from justoneapi import JustOneAPIClient # Read token from environment token = os.getenv("JUSTONEAPI_TOKEN") if not token: raise ValueError("JUSTONEAPI_TOKEN environment variable not set") client = JustOneAPIClient(token=token) ``` -------------------------------- ### Common Parameter Types - Time Filters Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Examples of how to apply time filters for Douyin and Xiaohongshu API requests. ```APIDOC ## Common Parameter Types - Time Filters ### Description Filter results based on publication time for Douyin or a specific time range for Xiaohongshu. ### Douyin Publish Time Filters - `"_0"`: No time limit. - `"_1"`: Last 24 hours. - `"_7"`: Last 7 days. - `"_180"`: Last 6 months. ### Xiaohongshu Time Range Filters - `"DAY_7"`: Last 7 days. - `"DAY_30"`: Last 30 days. ### Example Usage ```python # For Douyin publish time publish_time="_7" # Last 7 days response = client.douyin.some_method(publish_time=publish_time) # For Xiaohongshu time range nd="DAY_30" # Last 30 days response = client.xiaohongshu.some_method(nd=nd) ``` ``` -------------------------------- ### High-Performance Setup Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/configuration.md Configure the client for high-performance batch operations with a short timeout (10 seconds) to fail fast on slow endpoints. Business errors are checked via response codes rather than raising exceptions. ```python from justoneapi import JustOneAPIClient # For batch operations with multiple parallel requests client = JustOneAPIClient( token="your_token", timeout=10, # Shorter timeout to fail fast on slow endpoints raise_on_business_error=False # Check response codes, don't raise ) ``` -------------------------------- ### get_item_detail_v1 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Get product details from Taobao/Tmall. Returns product details including pricing, images, and shop information. ```APIDOC ## get_item_detail_v1 ### Description Get product details from Taobao/Tmall. ### Method GET (assumed, based on typical resource access patterns) ### Endpoint /taobao/item/detail/v1 ### Parameters #### Query Parameters - **item_id** (str) - Required - Unique product identifier (item ID). ### Response #### Success Response (200) - **data** (Any) - Contains product details including pricing, images, and shop information. ### Request Example ```python response = client.taobao.get_item_detail_v1(item_id="123456789") ``` ### Response Example ```json { "success": true, "data": { "title": "Example Product Title", "price": "199.00", "images": ["url1", "url2"], "shop_info": { "name": "Example Shop" } } } ``` ``` -------------------------------- ### Get Product Details Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Fetch detailed information about products from e-commerce platforms like Taobao/Tmall, JD.com, and 1688. ```APIDOC ## Get Product Details ### Description Fetches detailed information for a specific product from e-commerce platforms. ### Method client.get_item_detail_vX ### Parameters - **platform** (string) - Required - The e-commerce platform (e.g., 'TAOBAO', 'JD', 'FIELD_1688'). - **item_id** (string) - Required - The unique identifier of the product. ### Example ```python # Get Taobao/Tmall product details client.taobao.get_item_detail_v1(item_id="item_id") # Get JD.com product details client.jd.get_item_detail_v1(item_id="item_id") # Get 1688 product details client.field_1688.get_item_detail_v1(item_id="item_id") ``` ``` -------------------------------- ### Get User Profile Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Retrieve detailed user profile information for Douyin, Instagram, Weibo, and Xiaohongshu users. ```APIDOC ## Get User Profile ### Description Retrieves detailed profile information for a user on platforms like Douyin, Instagram, Weibo, and Xiaohongshu. ### Method client.get_user_detail_vX ### Parameters - **platform** (string) - Required - The platform to retrieve the user profile from (e.g., 'DOUYIN', 'INSTAGRAM', 'WEIBO', 'XIAOHONGSHU'). - **identifier** (string) - Required - The unique identifier for the user on the specified platform (e.g., 'sec_uid' for Douyin, 'username' for Instagram, 'uid' for Weibo, 'user_id' for Xiaohongshu). ### Example ```python # Get Douyin user profile client.douyin.get_user_detail_v3(sec_uid="user_id") # Get Instagram user profile client.instagram.get_user_detail_v1(username="username") # Get Weibo user profile client.weibo.get_user_detail_v3(uid="uid") # Get Xiaohongshu user profile client.xiaohongshu.get_user_detail_v1(user_id="user_id") ``` ``` -------------------------------- ### Client Initialization Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Initialize the JustOneAPIClient with your API token and optional parameters. ```APIDOC ## Client Initialization ### Description Initialize the JustOneAPIClient with your API token and optional parameters like base URL, timeout, and error handling. ### Method ```python JustOneAPIClient( token="your_api_token", # Required base_url="https://api.justoneapi.com", # Default timeout=60, # Default raise_on_business_error=False # Default ) ``` ``` -------------------------------- ### Common Parameter Types - Content Types Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Examples of how to specify content types or filters for Douyin and Instagram API requests. ```APIDOC ## Common Parameter Types - Content Types ### Description Filter results by content category for Douyin or specify included content types for Instagram. ### Douyin Content Types Examples include `"FASHION"`, `"TECHNOLOGY"`, `"GAME"`. Refer to `douyin-resource.md` for a full list. ### Instagram Content Filters - `"PICTURE"`: Include only pictures. - `"VIDEO"`: Include only videos. - `"MUSIC"`: Include content with music. - `"LINK"`: Include content with links. ### Example Usage ```python # For Douyin content type content_type="TECHNOLOGY" response = client.douyin.some_method(content_type=content_type) # For Instagram content filter contains="VIDEO" response = client.instagram.some_method(contains=contains) ``` ``` -------------------------------- ### Manage JustOneAPI Client Lifecycle Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Demonstrates the manual lifecycle of creating, using, and closing a `JustOneAPIClient`. Ensure the client is closed to release resources. ```python from justoneapi import JustOneAPIClient # Create client = JustOneAPIClient(token="your_token") # Use response = client.douyin.search_video_v4(keyword="test") # Close client.close() ``` -------------------------------- ### get_item_detail_v4 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/taobao-resource.md Get product details from Taobao/Tmall (v4). Returns product details including pricing, images, and shop details. ```APIDOC ## get_item_detail_v4 ### Description Get product details from Taobao/Tmall (v4). ### Method GET (assumed) ### Endpoint /taobao/item/detail/v4 ### Parameters #### Query Parameters - **item_id** (str) - Required - Unique product identifier (item ID). ### Response #### Success Response (200) - **data** (Any) - Contains product details including pricing, images, and shop details. ### Request Example ```python response = client.taobao.get_item_detail_v4(item_id="123456789") ``` ### Response Example ```json { "success": true, "data": { "title": "Example Product Title", "price": "199.00", "shop_name": "Example Shop", "shop_rating": "5.0" } } ``` ``` -------------------------------- ### Search V1 with Platform Selection Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/search-resource.md Illustrates how to specify platforms for the search query using the `source` parameter in the search_v1 method. ```APIDOC ## Platform Selection ### Search All Platforms ```python response = client.search.search_v1( keyword="test", source="ALL", start="2024-01-01 00:00:00", end="2024-01-31 23:59:59" ) ``` ### Search Specific Platforms ```python # Weibo only response = client.search.search_v1( keyword="test", source="WEIBO", start="2024-01-01 00:00:00", end="2024-01-31 23:59:59" ) # Douyin only response = client.search.search_v1( keyword="test", source="DOUYIN", start="2024-01-01 00:00:00", end="2024-01-31 23:59:59" ) # Multiple but not all (use one at a time) platforms = ["WEIBO", "DOUYIN", "XIAOHONGSHU"] for platform in platforms: response = client.search.search_v1( keyword="test", source=platform, start="2024-01-01 00:00:00", end="2024-01-31 23:59:59" ) ``` ``` -------------------------------- ### Get Note Comments v1 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Fetches comments for a specific note, supporting pagination with a last_cursor. Requires the note_id parameter. ```python def get_note_comments_v1( self, *, note_id: str, last_cursor: str | None = None, ) -> ApiResponse[Any] ``` -------------------------------- ### Get User Detail (v1) Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Fetch detailed profile information for a specific Xiaohongshu user using their unique ID. ```python response = client.xiaohongshu.get_user_detail_v1(user_id="user123") if response.success: user = response.data print(f"Name: {user.get('nickname')}") print(f"Followers: {user.get('follower_count')}") print(f"Verified: {user.get('verified')}") print(f"Bio: {user.get('bio')}") ``` -------------------------------- ### Get Douyin User Profile Details Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/douyin-resource.md Retrieves detailed profile information for a specific Douyin user using their sec_uid. ```python response = client.douyin.get_user_detail_v3(sec_uid="MS4wLjABAAAA...") if response.success: user = response.data print(f"Name: {user.get('nickname')}") print(f"Followers: {user.get('follower_count')}") print(f"Verified: {user.get('verified')}") ``` -------------------------------- ### Implement Context Manager for JustOneAPI Client Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/transport-and-auth.md Shows the `__enter__` and `__exit__` methods required for the `JustOneAPIClient` to function as a context manager. ```python def __enter__(self) -> "JustOneAPIClient": return self def __exit__(self, exc_type, exc, tb) -> None: self.close() ``` -------------------------------- ### Basic API Call with JustOneAPIClient Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/client.md Demonstrates a straightforward API call to search for videos. Always verify the 'success' flag in the response before processing data. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_api_token") response = client.douyin.search_video_v4(keyword="deepseek") # Always check success flag if response.success: print("Hits:", len(response.data.get("items", []))) else: print(f"Error: {response.code} - {response.message}") ``` -------------------------------- ### Get Douyin Video Details Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/douyin-resource.md Fetches detailed information for a specific Douyin video, including author and engagement metrics. ```python response = client.douyin.get_video_detail_v2(video_id="7123456789") if response.success: video = response.data print(f"Title: {video.get('title')}") print(f"Likes: {video.get('like_count')}") print(f"Comments: {video.get('comment_count')}") print(f"Author: {video.get('author', {}).get('unique_id')}") ``` -------------------------------- ### Resources Overview.md - All Platforms Index Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/README.md An overview of all supported platforms and common API conventions. ```APIDOC ## Resources Overview ### Description This document provides a comprehensive index of all 29 platforms supported by the Just One API, along with common method patterns, version management strategies, and parameter conventions used across the SDK. ### Key Information - **Platform Index**: A complete list of all supported platforms. - **Common Method Patterns**: Identifies recurring patterns in method naming and functionality across different platform resources. - **Version Management**: Explains how API versions are handled and how to specify them. - **Dynamic Registration**: Information on how new platforms or resources might be dynamically added or accessed. - **Parameter Conventions**: Details the standard conventions for naming and formatting parameters across all API calls. ``` -------------------------------- ### Get Note Detail v1 Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Retrieves detailed information for a specific note using its unique ID. Requires the note_id parameter. ```python def get_note_detail_v1( self, *, note_id: str, ) -> ApiResponse[Any] ``` -------------------------------- ### Initialize JustOneAPIClient Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/quick-reference.md Initialize the client with your API token. This client instance is used for all subsequent API calls. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_api_token") ``` -------------------------------- ### Get User Notes (v1) Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/xiaohongshu-resource.md Retrieve notes published by a specific user. Supports pagination using a `last_cursor` for iterating through all notes. ```python all_notes = [] last_cursor = None # Paginate through user's notes while True: response = client.xiaohongshu.get_user_note_list_v1( user_id="user123", last_cursor=last_cursor ) if not response.success: break notes = response.data.get('notes', []) if not notes: break all_notes.extend(notes) last_cursor = response.data.get('last_cursor') if not last_cursor: break print(f"Found {len(all_notes)} notes by user") ``` -------------------------------- ### Get Instagram User Details (v1) Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/instagram-resource.md Retrieve detailed profile information for a given Instagram username. Requires the username as a parameter. ```python from justoneapi import JustOneAPIClient client = JustOneAPIClient(token="your_token") response = client.instagram.get_user_detail_v1(username="testuser") if response.success: user = response.data print(f"Username: {user.get('username')}") print(f"Followers: {user.get('follower_count')}") print(f"Following: {user.get('following_count')}") print(f"Posts: {user.get('post_count')}") ``` -------------------------------- ### BaseResource Class Definition Source: https://github.com/justoneapi/justoneapi-python/blob/main/_autodocs/resources-overview.md The base class for all resources, providing initialization with a transport layer and a protected method for making GET requests. ```python class BaseResource: def __init__(self, transport: Transport): self._transport = transport def _get(self, path: str, params: dict[str, Any]) -> ApiResponse[Any]: return self._transport.get(path, params) ```