Operations 7
Documentation
Documentation
https://docs.ahrefs.com/docs/api/reference/introduction
APIReference
https://docs.ahrefs.com/en/api/reference/site-explorer
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/ahrefs-keywords-api"
curl "https://apis.io/api/v1/apis?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
openapi: 3.2.0
info:
title: Ahrefs Keywords API
version: 3.0.0
contact:
name: Ahrefs
url: https://ahrefs.com/
email: support@ahrefs.com
termsOfService: https://ahrefs.com/terms
description: 'Operations tagged Keywords across 2 of this provider''s published API definitions: ahrefs-gsc-openapi.json, ahrefs-management-openapi.json. Each path carries the servers of the definition it was published in.'
servers:
- url: https://api.ahrefs.com/v3/gsc
description: Ahrefs GSC Insights
- url: https://api.ahrefs.com/v3/management
description: Ahrefs Management
security:
- http:
- read
tags:
- name: Keywords
description: GSC keywords data
paths:
/keyword-history:
get:
tags:
- Keywords
summary: Keyword history
description: '>Requests to this endpoint are free and do not consume any API units.'
operationId: keyword-history
parameters:
- description: Project ID. Required when portfolio_id is not provided.
required: false
explode: false
schema:
type: integer
name: project_id
in: query
- description: Portfolio ID. When provided, aggregates data across all GSC-connected projects in the portfolio.
required: false
explode: false
schema:
type: integer
name: portfolio_id
in: query
- description: The start date of the historical period in YYYY-MM-DD format.
required: true
explode: false
schema:
type: string
format: date
name: date_from
in: query
- description: The end date of the historical period in YYYY-MM-DD format.
required: false
explode: false
schema:
type: string
format: date
name: date_to
in: query
- description: The time interval used to group historical data.
required: false
explode: false
schema:
type: string
enum:
- daily
- weekly
- monthly
default: monthly
name: history_grouping
in: query
- description: A two-letter country code (ISO 3166-1 alpha-2).
required: false
explode: false
schema:
type: string
enum:
- ad
- ae
- af
- ag
- ai
- al
- am
- ao
- ar
- as
- at
- au
- aw
- az
- ba
- bb
- bd
- be
- bf
- bg
- bh
- bi
- bj
- bn
- bo
- br
- bs
- bt
- bw
- by
- bz
- ca
- cd
- cf
- cg
- ch
- ci
- ck
- cl
- cm
- cn
- co
- cr
- cu
- cv
- cy
- cz
- de
- dj
- dk
- dm
- do
- dz
- ec
- ee
- eg
- es
- et
- fi
- fj
- fm
- fo
- fr
- ga
- gb
- gd
- ge
- gf
- gg
- gh
- gi
- gl
- gm
- gn
- gp
- gq
- gr
- gt
- gu
- gy
- hk
- hn
- hr
- ht
- hu
- id
- ie
- il
- im
- in
- iq
- is
- it
- je
- jm
- jo
- jp
- ke
- kg
- kh
- ki
- kn
- kr
- kw
- ky
- kz
- la
- lb
- lc
- li
- lk
- ls
- lt
- lu
- lv
- ly
- ma
- mc
- md
- me
- mg
- mk
- ml
- mm
- mn
- mq
- mr
- ms
- mt
- mu
- mv
- mw
- mx
- my
- mz
- na
- nc
- ne
- ng
- ni
- nl
- 'no'
- np
- nr
- nu
- nz
- om
- pa
- pe
- pf
- pg
- ph
- pk
- pl
- pn
- pr
- ps
- pt
- py
- qa
- re
- ro
- rs
- ru
- rw
- sa
- sb
- sc
- se
- sg
- sh
- si
- sk
- sl
- sm
- sn
- so
- sr
- st
- sv
- td
- tg
- th
- tj
- tk
- tl
- tm
- tn
- to
- tr
- tt
- tw
- tz
- ua
- ug
- us
- uy
- uz
- vc
- ve
- vg
- vi
- vn
- vu
- ws
- ye
- yt
- za
- zm
- zw
name: country
in: query
- description: Filter by device type (DESKTOP, MOBILE, TABLET). If not specified, all devices are included.
required: false
explode: false
schema:
type: string
enum:
- desktop
- mobile
- tablet
name: device
in: query
- description: A comma-separated list of keywords to get history data for.
required: false
explode: false
schema:
type: string
default: ''
name: keywords
in: query
- description: "Supported fields:\n- url\n\nFilter is a JSON string that represents a boolean expression, it should follow the following structure:\n```\n<bool_filter> ::= { \"and\" : <bool_filter>+ }\n | { \"or\" : <bool_filter>+ }\n | { \"not\" : <bool_filter> }\n | <expr>\n\n<expr> ::= {\n \"field\" : <dimension|metric>,\n ? \"is\": <condition>,\n }\n\n<condition> ::= [ \"eq\", <value> ]\n | [ \"neq\", <value> ]\n | [ \"gt\", <value> ]\n | [ \"gte\", <value> ]\n | [ \"lt\", <value> ]\n | [ \"lte\", <value> ]\n | [ \"substring\", <value> ]\n | [ \"isubstring\", <value> ]\n | [ \"phrase_match\", <value> ]\n | [ \"iphrase_match\", <value> ]\n | [ \"prefix\", <value> ]\n | [ \"suffix\", <value> ]\n```"
required: false
explode: false
schema:
type: string
name: where
in: query
- $ref: '#/components/parameters/output'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/keyword-history'
application/xml:
schema:
$ref: '#/components/schemas/keyword-history'
'400':
$ref: '#/components/responses/error_400'
'401':
$ref: '#/components/responses/error_401'
'403':
$ref: '#/components/responses/error_403'
'429':
$ref: '#/components/responses/error_429'
'500':
$ref: '#/components/responses/error_500'
servers:
- url: https://api.ahrefs.com/v3/gsc
description: Ahrefs GSC Insights
/keywords:
get:
tags:
- Keywords
summary: Keywords
description: '>Requests to this endpoint are free and do not consume any API units.'
operationId: keywords
parameters:
- description: Project ID. Required when portfolio_id is not provided.
required: false
explode: false
schema:
type: integer
name: project_id
in: query
- description: Portfolio ID. When provided, aggregates data across all GSC-connected projects in the portfolio.
required: false
explode: false
schema:
type: integer
name: portfolio_id
in: query
- description: The start date of the historical period in YYYY-MM-DD format.
required: true
explode: false
schema:
type: string
format: date
name: date_from
in: query
- description: The end date of the historical period in YYYY-MM-DD format.
required: false
explode: false
schema:
type: string
format: date
name: date_to
in: query
- description: The type of search results to return (web, image, video, news).
required: false
explode: false
schema:
type: string
enum:
- web
- image
- video
- news
default: web
name: search_type
in: query
- description: A two-letter country code (ISO 3166-1 alpha-2).
required: false
explode: false
schema:
type: string
enum:
- ad
- ae
- af
- ag
- ai
- al
- am
- ao
- ar
- as
- at
- au
- aw
- az
- ba
- bb
- bd
- be
- bf
- bg
- bh
- bi
- bj
- bn
- bo
- br
- bs
- bt
- bw
- by
- bz
- ca
- cd
- cf
- cg
- ch
- ci
- ck
- cl
- cm
- cn
- co
- cr
- cu
- cv
- cy
- cz
- de
- dj
- dk
- dm
- do
- dz
- ec
- ee
- eg
- es
- et
- fi
- fj
- fm
- fo
- fr
- ga
- gb
- gd
- ge
- gf
- gg
- gh
- gi
- gl
- gm
- gn
- gp
- gq
- gr
- gt
- gu
- gy
- hk
- hn
- hr
- ht
- hu
- id
- ie
- il
- im
- in
- iq
- is
- it
- je
- jm
- jo
- jp
- ke
- kg
- kh
- ki
- kn
- kr
- kw
- ky
- kz
- la
- lb
- lc
- li
- lk
- ls
- lt
- lu
- lv
- ly
- ma
- mc
- md
- me
- mg
- mk
- ml
- mm
- mn
- mq
- mr
- ms
- mt
- mu
- mv
- mw
- mx
- my
- mz
- na
- nc
- ne
- ng
- ni
- nl
- 'no'
- np
- nr
- nu
- nz
- om
- pa
- pe
- pf
- pg
- ph
- pk
- pl
- pn
- pr
- ps
- pt
- py
- qa
- re
- ro
- rs
- ru
- rw
- sa
- sb
- sc
- se
- sg
- sh
- si
- sk
- sl
- sm
- sn
- so
- sr
- st
- sv
- td
- tg
- th
- tj
- tk
- tl
- tm
- tn
- to
- tr
- tt
- tw
- tz
- ua
- ug
- us
- uy
- uz
- vc
- ve
- vg
- vi
- vn
- vu
- ws
- ye
- yt
- za
- zm
- zw
name: country
in: query
- description: Filter by device type (DESKTOP, MOBILE, TABLET). If not specified, all devices are included.
required: false
explode: false
schema:
type: string
enum:
- desktop
- mobile
- tablet
name: device
in: query
- description: The number of results to return.
required: false
explode: false
schema:
type: integer
default: 1000
name: limit
in: query
- description: "Supported fields:\n- keyword\n- top_url\n- url\n- clicks\n- impressions\n- ctr\n- position\n\nFilter is a JSON string that represents a boolean expression, it should follow the following structure:\n```\n<bool_filter> ::= { \"and\" : <bool_filter>+ }\n | { \"or\" : <bool_filter>+ }\n | { \"not\" : <bool_filter> }\n | <expr>\n\n<expr> ::= {\n \"field\" : <dimension|metric>,\n ? \"is\": <condition>,\n }\n\n<condition> ::= [ \"eq\", <value> ]\n | [ \"neq\", <value> ]\n | [ \"gt\", <value> ]\n | [ \"gte\", <value> ]\n | [ \"lt\", <value> ]\n | [ \"lte\", <value> ]\n | [ \"substring\", <value> ]\n | [ \"isubstring\", <value> ]\n | [ \"phrase_match\", <value> ]\n | [ \"iphrase_match\", <value> ]\n | [ \"prefix\", <value> ]\n | [ \"suffix\", <value> ]\n```"
required: false
explode: false
schema:
type: string
name: where
in: query
- description: The id of an existing keyword list to show metrics for.
required: false
explode: false
schema:
type: integer
name: keyword_list_id
in: query
- description: Keyword lists filter (JSON string). Supports include (is), exclude (is_not), empty (not in any list), and not_empty (in any list).
required: false
explode: false
schema:
type: string
name: keyword_lists
in: query
- $ref: '#/components/parameters/output_json_php_xml'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/keywords'
application/xml:
schema:
$ref: '#/components/schemas/keywords'
'400':
$ref: '#/components/responses/error_400'
'401':
$ref: '#/components/responses/error_401'
'403':
$ref: '#/components/responses/error_403'
'429':
$ref: '#/components/responses/error_429'
'500':
$ref: '#/components/responses/error_500'
servers:
- url: https://api.ahrefs.com/v3/gsc
description: Ahrefs GSC Insights
/project-keywords:
get:
tags:
- Keywords
summary: Keywords
description: '>Requests to this endpoint are free and do not consume any API units.'
operationId: project-keywords
parameters:
- description: 'The unique identifier of the project. You can find it in the URL of your Rank Tracker project in Ahrefs: `https://app.ahrefs.com/rank-tracker/overview/#project_id#`'
required: true
explode: false
schema:
type: integer
name: project_id
in: query
- $ref: '#/components/parameters/output_json_php_xml'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/project-keywords'
application/xml:
schema:
$ref: '#/components/schemas/project-keywords'
'400':
$ref: '#/components/responses/error_400'
'401':
$ref: '#/components/responses/error_401'
'403':
$ref: '#/components/responses/error_403'
'429':
$ref: '#/components/responses/error_429'
'500':
$ref: '#/components/responses/error_500'
put:
tags:
- Keywords
summary: Keywords
description: '>Requests to this endpoint are free and do not consume any API units.'
operationId: project-keywords
parameters:
- description: 'The unique identifier of the project. You can find it in the URL of your Rank Tracker project in Ahrefs: `https://app.ahrefs.com/rank-tracker/overview/#project_id#`'
required: true
explode: false
schema:
type: integer
name: project_id
in: query
- $ref: '#/components/parameters/output_json_php_xml'
requestBody:
content:
application/json:
schema:
properties:
keywords:
items:
properties:
keyword:
type: string
description: The keyword to add.
tags:
items:
type: string
type: array
description: A list of tags to assign to a given keyword.
type: object
required:
- keyword
type: array
minItems: 1
description: A list of keywords to add.
locations:
items:
properties:
country:
type: string
enum:
- ad
- ae
- af
- ag
- ai
- al
- am
- ao
- ar
- as
- at
- au
- aw
- az
- ba
- bb
- bd
- be
- bf
- bg
- bh
- bi
- bj
- bn
- bo
- br
- bs
- bt
- bw
- by
- bz
- ca
- cd
- cf
- cg
- ch
- ci
- ck
- cl
- cm
- cn
- co
- cr
- cu
- cv
- cy
- cz
- de
- dj
- dk
- dm
- do
- dz
- ec
- ee
- eg
- es
- et
- fi
- fj
- fm
- fo
- fr
- ga
- gb
- gd
- ge
- gf
- gg
- gh
- gi
- gl
- gm
- gn
- gp
- gq
- gr
- gt
- gu
- gy
- hk
- hn
- hr
- ht
- hu
- id
- ie
- il
- im
- in
- iq
- is
- it
- je
- jm
- jo
- jp
- ke
- kg
- kh
- ki
- kn
- kr
- kw
- ky
- kz
- la
- lb
- lc
- li
- lk
- ls
- lt
- lu
- lv
- ly
- ma
- mc
- md
- me
- mg
- mk
- ml
- mm
- mn
- mq
- mr
- ms
- mt
- mu
- mv
- mw
- mx
- my
- mz
- na
- nc
- ne
- ng
- ni
- nl
- 'no'
- np
- nr
- nu
- nz
- om
- pa
- pe
- pf
- pg
- ph
- pk
- pl
- pn
- pr
- ps
- pt
- py
- qa
- re
- ro
- rs
- ru
- rw
- sa
- sb
- sc
- se
- sg
- sh
- si
- sk
- sl
- sm
- sn
- so
- sr
- st
- sv
- td
- tg
- th
- tj
- tk
- tl
- tm
- tn
- to
- tr
- tt
- tw
- tz
- ua
- ug
- us
- uy
- uz
- vc
- ve
- vg
- vi
- vn
- vu
- ws
- ye
- yt
- za
- zm
- zw
description: A two-letter country code (ISO 3166-1 alpha-2).
location_id:
type: integer
description: The location ID.
language:
type: string
description: The location code.
type: object
required:
- country
type: array
minItems: 1
description: A list of locations to assign to given keywords. You can use the 'Locations and languages' endpoint to get country codes, language codes and location IDs.
type: object
required:
- keywords
- locations
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/project-keywords'
application/xml:
schema:
$ref: '#/components/schemas/project-keywords'
'400':
$ref: '#/components/responses/error_400'
'401':
$ref: '#/components/responses/error_401'
'403':
$ref: '#/components/responses/error_403'
'429':
$ref: '#/components/responses/error_429'
'500':
$ref: '#/components/responses/error_500'
servers:
- url: https://api.ahrefs.com/v3/management
description: Ahrefs Management
/project-keywords-delete:
put:
tags:
- Keywords
summary: Delete Keywords
description: '>Requests to this endpoint are free and do not consume any API units.'
operationId: project-keywords-delete
parameters:
- description: 'The unique identifier of the project. You can find it in the URL of your Rank Tracker project in Ahrefs: `https://app.ahrefs.com/rank-tracker/overview/#project_id#`'
required: true
explode: false
schema:
type: integer
name: project_id
in: query
- $ref: '#/components/parameters/output_json_php_xml'
requestBody:
content:
application/json:
schema:
properties:
keywords:
items:
properties:
keyword:
type: string
description: The keyword to delete.
country:
type: string
enum:
- ad
- ae
- af
- ag
- ai
- al
- am
- ao
- ar
- as
- at
- au
- aw
- az
- ba
- bb
- bd
- be
- bf
- bg
- bh
- bi
- bj
- bn
- bo
- br
- bs
- bt
- bw
- by
- bz
- ca
- cd
- cf
- cg
- ch
- ci
- ck
- cl
- cm
- cn
- co
- cr
- cu
- cv
- cy
- cz
- de
- dj
- dk
- dm
- do
- dz
- ec
- ee
- eg
- es
- et
- fi
- fj
- fm
- fo
- fr
- ga
- gb
- gd
- ge
- gf
- gg
- gh
- gi
- gl
- gm
- gn
- gp
- gq
- gr
- gt
- gu
- gy
- hk
- hn
- hr
- ht
- hu
- id
- ie
- il
- im
- in
- iq
- is
- it
- je
- jm
- jo
- jp
- ke
- kg
- kh
- ki
- kn
- kr
- kw
- ky
- kz
- la
- lb
- lc
- li
- lk
- ls
- lt
- lu
- lv
- ly
- ma
- mc
- md
- me
- mg
- mk
- ml
- mm
- mn
- mq
- mr
- ms
- mt
- mu
- mv
- mw
- mx
- my
- mz
- na
- nc
- ne
- ng
- ni
- nl
- 'no'
- np
- nr
- nu
- nz
- om
- pa
- pe
- pf
- pg
- ph
- pk
- pl
- pn
- pr
- ps
- pt
- py
- qa
- re
- ro
- rs
- ru
- rw
- sa
- sb
- sc
- se
- sg
- sh
- si
- sk
- sl
- sm
- sn
- so
- sr
- st
- sv
- td
- tg
- th
- tj
- tk
- tl
- tm
- tn
- to
- tr
- tt
- tw
- tz
- ua
- ug
- us
- uy
- uz
- v
# --- truncated at 32 KB (60 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/ahrefs/refs/heads/main/openapi/ahrefs-keywords-api-openapi.yml