How to set up API data extraction on Semrush
Setting up API data extraction on Semrush requires obtaining API credentials from your account dashboard, configuring authentication with your API key, and making structured HTTP requests to specific endpoints. The process involves generating an API key, understanding rate limits, and formatting requests correctly to extract keyword, domain, or competitor data programmatically.
Prerequisites
- Active Semrush subscription with API access
- Basic understanding of API concepts and HTTP requests
- Programming knowledge or API testing tool like Postman
- Valid domain or keywords for data extraction
Step-by-Step Instructions
Access your Semrush API credentials
Understand API rate limits and quotas
Choose your API endpoint and parameters
/domain_overviewfor domain metrics/phrase_organicfor organic keyword data/phrase_adwordsfor paid search data/backlinks_overviewfor backlink metrics
domain, phrase, database (country code), and optional parameters like limit and offset for pagination.Structure your API request
https://api.semrush.com/?type={report_type}&key={your_api_key}&domain={target_domain}&database={country_code}For example, to get domain overview data:
https://api.semrush.com/?type=domain_overview&key=YOUR_API_KEY&domain=example.com&database=usAdd additional parameters as needed based on your chosen endpoint and data requirements.
Set up authentication and headers
Test your API connection
domain_overview with a known domain. Verify you receive a successful HTTP 200 response with data in CSV or JSON format (depending on your format parameter). Check the response headers for remaining quota information. Parse the response to ensure data is formatted as expected and contains the metrics you need.Implement data parsing and storage
Monitor and optimize your extraction process
Common Issues & Troubleshooting
Getting 403 Forbidden or authentication errors
Verify your API key is correct and hasn't expired. Check that your subscription plan includes API access. Ensure the API key is properly included in the request URL as the key parameter. Contact Semrush support if your account should have API access but you're still getting authentication errors.
Hitting rate limits with 429 Too Many Requests errors
Implement request throttling to stay under 10 requests per second. Add delays between requests using sleep() functions or rate limiting libraries. Monitor your request frequency and implement exponential backoff when receiving 429 responses. Consider spreading large extractions across multiple days to stay within daily quotas.
Receiving empty results or 'not found' responses
Verify the domain or keyword exists in Semrush's database for your selected country (database parameter). Check that you're using the correct database code (e.g., 'us' for United States, 'uk' for United Kingdom). Some domains may not have sufficient data in certain regions. Try different database parameters or verify the domain has organic/paid search presence.
API responses are incomplete or missing expected data
Check your subscription plan's API access level, as some reports require higher-tier plans. Verify you're using the correct endpoint parameters and haven't exceeded the maximum limit value for the endpoint. Use pagination with offset parameter for large datasets. Ensure the domain has sufficient search visibility for the requested metrics.