Skip to content

Latest commit

History

79 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

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 issuesGitHub 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

fromdataforseo_clientimportconfigurationasdfs_config, api_clientasdfs_api_providerfromdataforseo_client.api.serp_apiimportSerpApifromdataforseo_client.restimportApiExceptionfromdataforseo_client.models.serp_google_organic_live_advanced_request_infoimportSerpGoogleOrganicLiveAdvancedRequestInfofrompprintimportpprint# Configure HTTP basic authorization: basicAuthconfiguration=dfs_config.Configuration(username='USERNAME',password='PASSWORD')
withdfs_api_provider.ApiClient(configuration) asapi_client:
# Create an instance of the API classserp_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)
exceptApiExceptionase:
print("Exception: %s\n"%e)

Example of Task-Based request

fromdataforseo_clientimportconfigurationasdfs_config, api_clientasdfs_api_providerfromdataforseo_client.api.serp_apiimportSerpApifromdataforseo_client.restimportApiExceptionfromdataforseo_client.models.serp_task_request_infoimportSerpTaskRequestInfofrompprintimportpprintimportasyncioimporttime# Configure HTTP basic authorization: basicAuthconfiguration=dfs_config.Configuration(username='USERNAME',password='PASSWORD')
defGoogleOrganicTaskReady(id):
result=serp_api.google_organic_tasks_ready()
returnany(any(xx.id==idforxxinx.result) forxinresult.tasks)
withdfs_api_provider.ApiClient(configuration) asapi_client:
# Create an instance of the API classserp_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].idstart_time=time.time()
whileGoogleOrganicTaskReady(task_id) isnotTrueand (time.time() -start_time) <60:
asyncio.sleep(1) api_response=serp_api.google_organic_task_get_advanced(id=task_id)
pprint(api_response)
exceptApiExceptionase:
print("Exception: %s\n"%e)

About

Official DataForSEO python client

Resources

Stars

47 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages