This is a C# 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.
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):
- SERP (source docs | api docs)
- Keywords Data (source docs | api docs)
- Domain Analytics (source docs | api docs)
- DataForSEO Labs (source docs | api docs)
- Backlinks (source docs | api docs)
- OnPage (source docs | api docs)
- Content Analysis (source docs | api docs)
- Content Generation (source docs | api docs)
- Merchant (source docs | api docs)
- AppData (source docs | api docs)
- Business Data (source docs | api docs)
- Appendix (source docs | api docs)
API Contains 2 types of requests:
- Live (Simple HTTP request/response message)
- 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
Our API description is based on the OpenAPI syntax in YAML format. The YAML file attached to the project with the name here
Code generated using the NSwag lib
The documentation for code objects, formatted in the Markdown (.md) is available here. Official documentation for DataForSEO APIs is available here.
dotnet add package DataForSeo.Client
Example of live request
var dfsClient = new DataForSeoClient(new DataForSeoClientConfiguration()
{
Username = "USERNAME",
Password = "PASSWORD",
});
var result = await dfsClient.SerpApi.GoogleOrganicLiveAdvancedAsync(new List<SerpGoogleOrganicLiveAdvancedRequestInfo>()
{
new()
{
LanguageCode = "en",
LocationCode = 2840,
Keyword = "albert einstein",
CalculateRectangles = true,
}
});
Example of Task-based request
var dfsClient = new DataForSeoClient(new DataForSeoClientConfiguration()
{
Username = "USERNAME",
Password = "PASSWORD",
});
var result = await dfsClient.SerpApi.GoogleOrganicTaskPostAsync(new List<SerpTaskRequestInfo>()
{
new()
{
LanguageCode = "en",
LocationCode = 2840,
Keyword = "albert einstein",
Priority = 2,
}
});
var sw = Stopwatch.StartNew();
var id = result.Tasks.First().Id;
while (!await GoogleOrganicTaskReady(id) && sw.Elapsed < TimeSpan.FromMinutes(1))
await Task.Delay(1_000);
var taskGetResult = await dfsClient.SerpApi.GoogleOrganicTaskGetAdvancedAsync(id);
async Task<bool> GoogleOrganicTaskReady(string id)
{
var result = await dfsClient.SerpApi.GoogleOrganicTasksReadyAsync();
return result.Tasks?.Any(x => x.Result?.Any(xx => xx.Id == id) ?? false) ?? false;
}