Skip to main content

DataForSEO API documentation

Project description

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_google_organic_task_post_request_info import SerpGoogleOrganicTaskPostRequestInfo
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([SerpGoogleOrganicTaskPostRequestInfo(
            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:
           time.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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataforseo_client-2.0.2.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

dataforseo_client-2.0.2-py3-none-any.whl (5.8 MB view details)

Uploaded Python 3

File details

Details for the file dataforseo_client-2.0.2.tar.gz.

File metadata

  • Download URL: dataforseo_client-2.0.2.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for dataforseo_client-2.0.2.tar.gz
Algorithm Hash digest
SHA256 d67fcc63c0bc29677e4b1b45adad26a7e112af2d388044afc41ea65b50e117af
MD5 85f018b5e52e00e36c672e67c8c6ab97
BLAKE2b-256 c8f4fab9d5792eb240fb3b98b2ff245330239bc97b7d3b341b98d24815fc4c8f

See more details on using hashes here.

File details

Details for the file dataforseo_client-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dataforseo_client-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8806264238a909574928e16ef40edc72fc75c1d6004b0ce83239011710e3a84
MD5 df451d44f3fdf952ea762a4b20409af0
BLAKE2b-256 47311ae9bd25d36f66e9eee2bbc7caf3735c5ad4eb8e2e82b1843c9fe506ed4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page