DataForSeo provides comprehensive SEO and digital marketing data solutions via API. TheThis notebook demonstrates how to use the DataForSeo API to obtain search engine results.DataForSeo API
retrievesSERP
from the most popular search engines likeBing
,Yahoo
. It also allows to >get SERPs from different search engine types likeMaps
,News
,Events
, etc.
Setting up the API credentials
You can obtain your API credentials by registering on theDataForSeo
website.
The Difference Between run
and results
run
and results
are two methods provided by the DataForSeoAPIWrapper
class.
The run
method executes the search and returns the first result snippet from the answer box, knowledge graph, featured snippet, shopping, or organic results. These elements are sorted by priority from highest to lowest.
The results
method returns a JSON response configured according to the parameters set in the wrapper. This allows for more flexibility in terms of what data you want to return from the API.
Getting Results as JSON
You can customize the result types and fields you want to return in the JSON response. You can also set a maximum count for the number of top results to return.Customizing Location and Language
You can specify the location and language of your search results by passing additional parameters to the API wrapper.Customizing the Search Engine
You can also specify the search engine you want to use.Customizing the Search Type
The API wrapper also allows you to specify the type of search you want to perform. For example, you can perform a maps search.Integration with LangChain Agents
You can use theTool
class from the langchain.agents
module to integrate the DataForSeoAPIWrapper
with a langchain agent. The Tool
class encapsulates a function that the agent can call.