Giter Site home page Giter Site logo

pythonclient's Introduction

OVERVIEW

There is a Python client to call DataForSeo API.

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 applying our API to almost all programming languages.

Client contains 12 sections (aka API):

API Contains 2 types of requests:

  1. Live (Simple HTTP request/response message)
  2. Task-Based (Where you need to send a 'Task' entity to execute, waiting until the 'Task' status is ready and getting the 'Task' result in a special endpoint. Usually, it represents in 3 endpoints 'TaskPost', 'TaskReady' and 'TaskGet')

For more details - please follow here

YAML Spec

Our API description is based on 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. Offical documentation for DataForSeo API is avaliable here.

Code generation

Code generated with using openapi generator cli

install package from nuget.org

pip install dataforseo-client 

Examples of usage

Example of live request

from __future__ import print_function
import time

import dataforseo_client
from dataforseo_client.rest import ApiException
from pprint import pprint
import asyncio
# Configure HTTP basic authorization: basicAuth
configuration = dataforseo_client.Configuration()
configuration.username = 'USERNAME'
configuration.password = 'PASSWORD'

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


    try:

        api_response = serp_api.google_organic_live_advanced([dataforseo_client.SerpTaskRequestInfo(
            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 __future__ import print_function
import time

import dataforseo_client
from dataforseo_client.rest import ApiException
from pprint import pprint
import asyncio
# Configure HTTP basic authorization: basicAuth
configuration = dataforseo_client.Configuration()
configuration.username = 'USERNAME'
configuration.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 dataforseo_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    serp_api = dataforseo_client.SerpApi(api_client)


    try:

        task_post = serp_api.google_organic_task_post([dataforseo_client.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) 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)

pythonclient's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.