DEV Community

Apollo
Apollo

Posted on

The Fastest Way to Add SEO Keyword Extraction to Any App

The Fastest Way to Add SEO Keyword Extraction to Any App

As a developer, I’ve often needed to extract SEO keywords from text for various applications—whether it’s analyzing blog posts, optimizing product descriptions, or improving search rankings. While there are many tools out there, most are either expensive or too complex to integrate into existing apps. That’s why I decided to explore REST APIs for Natural Language Processing (NLP) as a lightweight, cost-effective solution.

In this article, I’ll walk you through how to add SEO keyword extraction to any app using free and efficient REST APIs. I’ll share real code snippets, practical examples, and lessons learned along the way.

Why REST APIs for SEO Keyword Extraction?

REST APIs are a developer’s best friend when it comes to adding advanced functionalities without reinventing the wheel. Instead of training your own NLP models or paying for expensive SaaS tools, you can leverage existing APIs to extract keywords quickly and effectively.

I’ve tested several free NLP APIs, and here’s why they stand out:

  • Speed: Most APIs process text in milliseconds.
  • Cost: Many offer free tiers or generous usage limits.
  • Ease of Use: REST APIs are straightforward to integrate with minimal setup.

Step 1: Choosing the Right API

After evaluating a few options, I narrowed it down to two free APIs that work exceptionally well for keyword extraction:

  1. RapidAPI’s Keyword Extraction API: Offers a free tier with 100 requests per month.
  2. MeaningCloud’s Keyword Extraction API: Provides 40,000 free requests per month.

For this tutorial, I’ll focus on MeaningCloud because of its higher free-tier limit and accuracy.

Step 2: Getting Started with MeaningCloud

First, sign up for a free account on MeaningCloud and get your API key. You’ll need this to authenticate your requests.

Here’s a quick example of how to extract keywords using MeaningCloud’s API in Python:

import requests

def extract_keywords(text, api_key):
    url = "https://api.meaningcloud.com/topics-2.0"
    payload = {
        'key': api_key,
        'txt': text,
        'lang': 'en',
        'tt': 'a'  # 'a' stands for 'all topics'
    }
    response = requests.post(url, data=payload)
    if response.status_code == 200:
        data = response.json()
        keywords = [topic['form'] for topic in data['topic_list'] if topic['tt'] == 'NOUN']
        return keywords
    else:
        print(f"Error: {response.status_code}")
        return []

# Example usage
text = "The best way to boost your SEO is by using targeted keywords and optimizing your content."
api_key = 'YOUR_API_KEY'
keywords = extract_keywords(text, api_key)
print(keywords)  # Output: ['SEO', 'keywords', 'content']
Enter fullscreen mode Exit fullscreen mode

In this example, the API extracts keywords from the text and returns nouns, which are often the most relevant terms for SEO.

Step 3: Integrating with Your App

Let’s say you’re building a blog analytics tool and want to extract keywords from user-submitted articles. Here’s how you can integrate MeaningCloud’s API into a Flask app:

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/extract-keywords', methods=['POST'])
def extract_keywords_endpoint():
    data = request.json
    text = data.get('text')
    if not text:
        return jsonify({'error': 'No text provided'}), 400

    api_key = 'YOUR_API_KEY'
    keywords = extract_keywords(text, api_key)
    return jsonify({'keywords': keywords})

def extract_keywords(text, api_key):
    url = "https://api.meaningcloud.com/topics-2.0"
    payload = {
        'key': api_key,
        'txt': text,
        'lang': 'en',
        'tt': 'a'
    }
    response = requests.post(url, data=payload)
    if response.status_code == 200:
        data = response.json()
        keywords = [topic['form'] for topic in data['topic_list'] if topic['tt'] == 'NOUN']
        return keywords
    else:
        return []

if __name__ == '__main__':
    app.run(debug=True)
Enter fullscreen mode Exit fullscreen mode

This endpoint accepts JSON data with a text field, extracts keywords, and returns them in the response.

Step 4: Optimizing Performance

While MeaningCloud’s API is fast, here are a few tips to optimize performance further:

  1. Batch Processing: If you’re analyzing multiple articles, send them in batches to reduce API calls.
  2. Caching: Store frequently analyzed text and their keywords in a database to avoid redundant API requests.
  3. Throttling: Respect the API’s rate limits to avoid getting blocked.

Lessons Learned

  1. Free APIs Have Limits: While MeaningCloud’s free tier is generous, it’s essential to monitor usage and upgrade if needed.
  2. Accuracy Matters: Not all APIs are created equal. MeaningCloud’s focus on nouns (e.g., “SEO,” “keywords”) made it more accurate for SEO purposes compared to others.
  3. Keep It Simple: REST APIs are perfect for MVP (Minimum Viable Product) development. As your app scales, consider more advanced NLP solutions.

Conclusion

Adding SEO keyword extraction to your app doesn’t have to be complicated or expensive. By leveraging REST APIs like MeaningCloud, you can integrate this functionality quickly and cost-effectively. Whether you’re analyzing blog posts, optimizing product descriptions, or improving search rankings, this approach simplifies the process and delivers actionable results.

Start experimenting with NLP APIs today, and watch your app’s SEO capabilities soar!


🔑 Free API Access

The API I described is live at apollo-rapidapi.onrender.com — free tier available. For heavier usage, there's a $9/mo Pro plan with 50k requests/month.

More developer tools at apolloagmanager.github.io/apollo-ai-store

Top comments (0)