There is a C# 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):
- Serp (source docs | api docs)
- KeywordsData (source docs | api docs)
- DomainAnalytics (source docs | api docs)
- DataforseoLabs (source docs | api docs)
- Backlinks (source docs | api docs)
- OnPage (source docs | api docs)
- ContentAnalysis (source docs | api docs)
- ContentGeneration (source docs | api docs)
- Merchant (source docs | api docs)
- AppData (source docs | api docs)
- BusinessData (source docs | api docs)
- Appendix (source docs | api docs)
API Contains 2 types of requests:
- Live (Simple HTTP request/response message)
- 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
Our API description is based on openAPI syntax in YAML format. The YAML file attached to the project with the name here
Code generated with using NSwag lib
The documentation for code objects, formatted in Markdown (.md) is available here. Offical documentation for DataForSeo API is avaliable here.
dotnet add package DataForSeo.Client Example of live request
var dfsClient = new DataForSeoClient("USERNAME", "PASSWORD");
var result = await dfsClient.SerpApi.GoogleOrganicLiveAdvancedAsync(new List<SerpTaskRequestInfo>()
{
new()
{
LanguageCode = "en",
LocationCode = 2840,
Keyword = "albert einstein",
Priority = 2,
}
});Example of Task-based request
var dfsClient = new DataForSeoClient("USERNAME", "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;
}