MCPcopy Index your code
hub / github.com/dataforseo/PythonClient

github.com/dataforseo/PythonClient @v2.0.27

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.27 ↗ · + Follow
19,026 symbols 97,743 edges 2,789 files 2,814 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OVERVIEW

This is a Python client providing you, as a developer, with a tool for obtaining the necessary data from DataForSEO APIs. You don't have to figure out how to make a request and process a response - all that is readily available in this client.

GitHub issues GitHub license

DataForSEO API uses REST technology for interchanging data between your application and our service. The data exchange is made through the widely used HTTP protocol, which allows using our API with almost any programming language.

Client contains 12 sections (aka APIs):

API Contains 2 types of requests:

1) Live (Simple HTTP request/response message) 2) Task-based (Requires sending a 'Task' entity to execute, waiting until the 'Task' status is ready, and getting the 'Task' result in a special endpoint. Usually, it is represented by 3 types of endpoints: 'TaskPost', 'TaskReady', and 'TaskGet') For more details - please follow here

YAML Spec

Our API description is based on the OpenAPI syntax in YAML format. The YAML file attached to the project here

Documentation

The documentation for code objects, formatted in Markdown (.md) is available here. Official documentation for DataForSEO API is available here.

Code generation

Code generated using the openapi generator cli

Install package from nuget.org

pip install dataforseo-client 

Examples of usage

Example of live request

from dataforseo_client import configuration as dfs_config, api_client as dfs_api_provider
from dataforseo_client.api.serp_api import SerpApi
from dataforseo_client.rest import ApiException
from dataforseo_client.models.serp_google_organic_live_advanced_request_info import SerpGoogleOrganicLiveAdvancedRequestInfo
from pprint import pprint

# Configure HTTP basic authorization: basicAuth
configuration = dfs_config.Configuration(username='USERNAME',password='PASSWORD')
with dfs_api_provider.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    serp_api = SerpApi(api_client)

    try:

        api_response = serp_api.google_organic_live_advanced([SerpGoogleOrganicLiveAdvancedRequestInfo(
            language_name="English",
            location_name="United States",
            keyword="albert einstein"
        )])

        pprint(api_response)

    except ApiException as e:
        print("Exception: %s\n" % e)

Example of Task-Based request

from dataforseo_client import configuration as dfs_config, api_client as dfs_api_provider
from dataforseo_client.api.serp_api import SerpApi
from dataforseo_client.rest import ApiException
from dataforseo_client.models.serp_task_request_info import SerpTaskRequestInfo
from pprint import pprint
import asyncio
import time

# Configure HTTP basic authorization: basicAuth
configuration = dfs_config.Configuration(username='USERNAME',password='PASSWORD')

def GoogleOrganicTaskReady(id):
    result = serp_api.google_organic_tasks_ready()
    return any(any(xx.id == id for xx in x.result) for x in result.tasks)

with dfs_api_provider.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    serp_api = SerpApi(api_client)

    try:

        task_post = serp_api.google_organic_task_post([SerpTaskRequestInfo(
            language_name="English",
            location_name="United States",
            keyword="albert einstein"
        )])

        task_id = task_post.tasks[0].id

        start_time = time.time()

        while GoogleOrganicTaskReady(task_id) is not True and (time.time() - start_time) < 60:
           asyncio.sleep(1) 

        api_response = serp_api.google_organic_task_get_advanced(id=task_id)

        pprint(api_response)

    except ApiException as e:
        print("Exception: %s\n" % e)

Core symbols most depended-on inside this repo

call_api
called by 1713
dataforseo_client/api_client.py
read
called by 1143
dataforseo_client/rest.py
response_deserialize
called by 1142
dataforseo_client/api_client.py
param_serialize
called by 571
dataforseo_client/api_client.py
select_header_accept
called by 571
dataforseo_client/api_client.py
select_header_content_type
called by 272
dataforseo_client/api_client.py
get_default
called by 14
dataforseo_client/api_client.py
sanitize_for_serialization
called by 5
dataforseo_client/api_client.py

Shape

Method 16,222
Class 2,796
Function 8

Languages

Python100%

Modules by API surface

dataforseo_client/api/serp_api.py726 symbols
dataforseo_client/api/keywords_data_api.py282 symbols
dataforseo_client/api/business_data_api.py222 symbols
dataforseo_client/api/dataforseo_labs_api.py190 symbols
dataforseo_client/api/ai_optimization_api.py178 symbols
dataforseo_client/api/app_data_api.py170 symbols
dataforseo_client/api/merchant_api.py154 symbols
dataforseo_client/api/on_page_api.py126 symbols
dataforseo_client/api/backlinks_api.py98 symbols
dataforseo_client/api/domain_analytics_api.py58 symbols
dataforseo_client/api/content_analysis_api.py46 symbols
dataforseo_client/api/content_generation_api.py42 symbols

For agents

$ claude mcp add PythonClient \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact