cURL php NodeJS Python cSharp cURL php NodeJS Python cSharp


To authorize, use this code:

//You can download this file from here

try {
    //Instead of 'login' and 'password' use your credentials from
    $client = new RestClient('', null, 'login', 'password');

    //do something

} catch (RestClientException $e) {
    echo "\n";
    print "HTTP code: {$e->getHttpCode()}\n";
    print "Error code: {$e->getCode()}\n";
    print "Message: {$e->getMessage()}\n";
    print  $e->getTraceAsString();
    echo "\n";

Instead of ‘login’ and ‘password’ use your credentials from

Create an account with DataForSEO and then use the credentials from your account dashboard to access DataForSEO APIs. Note that the API password is generated automatically by DataForSEO and is different from your account password.

DataForSEO is using the Basic Authentication, which makes it possible to call our APIs with almost any programming language, Postman app, REST API platforms, and all major frameworks.

Regardless of the programming language, your unique API token should be passed in the ‘Authorization’ header within the request in the following format:
Authorization: Basic login:password

Instead of “login” and “password”, use your API credentials encoded in Base64.
For instance, the Base64-encoded ‘login:password’ value will have the following format:

So the whole string will look as follows:
Authorization: Basic bG9naW46cGFzc3dvcmQ=

Check the examples for PHP, Python, and C# on the right to see how it works with a particular programming language.

Note that it is not possible to pass the login and password in URL parameters. Also, you do not have to make a separate authentication call to obtain API credentials. Basic authentication is the only way to access DataForSEO API; credentials should always be passed in the header of the request.