Ahrefs APIA more powerful way to unlock the full potential to Ahrefs top-notch data

Integrations - How to Start

API calls require authorization, and are made on behalf of an authorized user. In order to do that, an application will need to be granted an API access token from user. The procedure is different depending on the application type (web or desktop).

For web applications:

1. Generate the "state" request parameter (opaque to the user) to maintain state between request and callback (see RFC6749 section 4.1.1).

2. Redirect the user to the invitation URL shown in your apps list, appending the generated "state" parameter to the request.

3. The user will see the authorization prompt. If he or she chooses to authorize your application to spend API rows, the service will redirect the user back to the redirect URL provided by you when submitting your application.

4. Check the "state" parameter to make sure the callback was made for your request.

5. The callback request will include the "code" parameter your application must use when requesting the access token.

7. If the access token request is valid and authorized, the service will return the successful JSON response:

{
"access_token":"<token you can use when performing API requests>",
"expires_in":<expiry interval>,
"token_type":"bearer",
"scope":"api",
"refresh_token":"<token you can use to retrieve the new API token>"
}

For desktop applications:

1. Generate the "state" request parameter (opaque to the user) to maintain state between request and callback (see RFC6749 section 4.1.1).

2. Redirect the user to the invitation URL shown in your apps list, appending the generated "state" parameter to the request.

3. The user will see the authorization prompt. If he or she chooses to authorize your application to spend API rows, the service will redirect the user back to the redirect URL provided by you when submitting your application.

4. Check the "state" parameter to make sure the callback was made for your request.

5. The callback request will include the "token" parameter you can use when performing API requests.

7 days. 7 dollars. Full access.

7-day trial gives you full access to all tools and features of the chosen plan.