← Back to articles
Free API Overview

Free Entity Linking API Complete Tutorial: Link Entities to Knowledge Base at Zero Cost (2026-11-13 Verified)

Free Entity Linking API: A Comprehensive Guide

Entity Linking (EL), also known as Named Entity Disambiguation (NED), is the process of mapping entity mentions in unstructured text to their corresponding unique entries in a target knowledge base, such as Wikipedia, DBpedia, or Wikidata. For example, when a news article mentions "Apple," an Entity Linking system determines whether it refers to the fruit or the technology company based on the surrounding context. This capability is a critical foundational step in knowledge graph construction, advanced question answering systems, semantic search, and robust information retrieval.

While commercial Entity Linking APIs can be expensive, the open-source community has developed several powerful, free alternatives. This tutorial explores four outstanding free Entity Linking solutions, compares their capabilities, and provides a practical case study.

1. SpaCy Entity Linker

SpaCy is a widely used open-source library for advanced Natural Language Processing (NLP) in Python. The spacy-entity-linker package extends SpaCy's pipeline to perform Entity Linking against Wikipedia. It leverages a pre-trained knowledge base (KB) and matches named entities extracted by SpaCy to Wikipedia articles using a context-aware similarity scoring mechanism.

Pros:

  • Seamless integration with existing SpaCy NLP pipelines.
  • Runs entirely locally without requiring external API calls.
  • Highly customizable if you train your own knowledge base.

Cons:

  • Requires downloading a large knowledge base file.
  • Currently primarily supports English Wikipedia.
import spacy

# Load a medium English model with NER and word vectors
nlp = spacy.load("en_core_web_md")

# Add the entity linker to the pipeline
# The linker uses Wikipedia as its knowledge base
if "entity_linker" not in nlp.pipe_names:
    nlp.add_pipe("entity_linker", config={
        "kb_encoder_type": "hash",
        "kb_reader_type": "default",
        "candidate_selector_type": "approx",
        "incl_prior": True,
        "incl_context": True
    })

# Sample text containing ambiguous entity mentions
text = "Apple is headquartered in Cupertino. Tim Cook is the CEO."

# Process the text through the full pipeline
doc = nlp(text)

# Iterate over linked entities and print KB identifiers
for ent in doc.ents:
    kb_ids = [kb.kb_id_ for kb in ent._.linked_entities]
    descriptions = [kb.description_ for kb in ent._.linked_entities]
    print(f"Entity: {ent.text}, Label: {ent.label_}, KB IDs: {kb_ids}")

2. Wikipedia2Vec + Nearest Neighbor

Wikipedia2Vec is a toolkit developed by Yahoo Japan for learning embeddings of words and entities from Wikipedia. It represents both words and entities in the same continuous vector space. By combining a traditional Named Entity Recognition (NER) system with Wikipedia2Vec embeddings, developers can build a custom Entity Linking pipeline. Once an entity mention is extracted, its context is embedded, and a nearest neighbor search is performed against the Wikipedia2Vec entity vectors to find the best match.

Pros:

  • Extremely fast during inference if approximate nearest neighbor (ANN) libraries like FAISS are used.
  • Highly flexible; you can swap out the NER model or the vector database.
  • Supports multiple languages.

Cons:

  • Requires manual assembly of the NER and vector search pipeline.
  • You must handle the candidate generation step yourself.
from wikipedia2vec import Wikipedia2Vec
import numpy as np
from sklearn.neighbors import NearestNeighbors

# Load pre-trained model (download from the official release page)
kv_model = Wikipedia2Vec.load("enwiki_20180420_100d.pkl")

# Build a nearest neighbor index over all entity vectors
all_entities = list(kv_model.dictionary.entities())
entity_vectors = np.array([kv_model.get_entity_vector(e.title) for e in all_entities])

# Use cosine similarity via NearestNeighbors
nn_index = NearestNeighbors(n_neighbors=5, metric="cosine")
nn_index.fit(entity_vectors)

def link_entity(mention: str, context: str = ""):
    """Link a mention to the most similar Wikipedia entity."""
    # Step 1: candidate generation by exact title match
    candidates = []
    try:
        ent = kv_model.get_entity(mention)
        candidates.append(ent)
    except KeyError:
        pass

    # Step 2: if no exact match, use word vector to find nearest entities
    if not candidates:
        try:
            word_vec = kv_model.get_word_vector(mention.lower())
            query = word_vec.reshape(1, -1)
            distances, indices = nn_index.kneighbors(query)
            for idx in indices[0]:
                candidates.append(all_entities[idx])
        except KeyError:
            return None

    # Step 3: if context provided, rerank candidates by context similarity
    if context and candidates:
        context_words = context.lower().split()
        context_vec = np.zeros(100)
        count = 0
        for w in context_words:
            try:
                context_vec += kv_model.get_word_vector(w)
                count += 1
            except KeyError:
                continue
        if count > 0:
            context_vec /= count
            scores = []
            for c in candidates:
                score = np.dot(c.vector, context_vec) / (
                    np.linalg.norm(c.vector) * np.linalg.norm(context_vec) + 1e-8
                )
                scores.append(score)
            best = candidates[int(np.argmax(scores))]
            return best.title

    return candidates[0].title if candidates else None

3. DBpedia Spotlight API

DBpedia Spotlight is a well-established system for annotating mentions of DBpedia resources in text. It provides a free public REST API that allows developers to send text and receive linked entities annotated with DBpedia URIs. The system works by spotting entity mentions, generating candidates, and disambiguating them using context vectors derived from DBpedia abstracts.

Pros:

  • Free public API requires no local setup or computational resources.
  • Links directly to DBpedia, which is rich in structured, RDF-based data.
  • Supports multiple languages including English, German, French, and Spanish.

Cons:

  • Rate-limited and occasionally unstable due to high traffic on the public endpoint.
  • Depends on external servers, which might raise data privacy concerns.
import requests

# DBpedia Spotlight public endpoint (free, no API key required)
SPOTLIGHT_URL = "https://api.dbpedia-spotlight.org/en/annotate"

def spotlight_link(text: str, confidence: float = 0.5, support: int = 20):
    """Call DBpedia Spotlight to link entities in text."""
    params = {
        "text": text,
        "confidence": confidence,
        "support": support,
        "format": "application/json"
    }
    headers = {"Accept": "application/json"}

    # Send GET request to the Spotlight endpoint
    response = requests.get(SPOTLIGHT_URL, params=params, headers=headers, timeout=30)
    response.raise_for_status()
    data = response.json()

    # Parse the returned Resources array
    resources = data.get("Resources", [])
    results = []
    for res in resources:
        results.append({
            "surface": res.get("@surfaceForm"),
            "uri": res.get("@URI"),
            "types": res.get("@types"),
            "confidence": float(res.get("@similarityScore", 0))
        })
    return results

# Example usage
text = "Barack Obama was born in Hawaii and served as President of the United States."
linked = spotlight_link(text, confidence=0.4)
for item in linked:
    print(f"Mention: {item['surface']}, URI: {item['uri']}, Confidence: {item['confidence']:.3f}")

BLINK (Bi-encoder Representations for Entities) is a state-of-the-art Entity Linking model developed by Facebook AI Research. It uses a bi-encoder architecture to independently embed the entity mention context and the entity descriptions, followed by a cross-encoder to rerank the top candidates. ReBel (Relation Extraction and Entity Linking) takes this further by jointly performing relation extraction and entity linking in a zero-shot manner.

Pros:

  • State-of-the-art accuracy on standard benchmarks.
  • Zero-shot capability allows it to link entities not seen during training.
  • Can be linked to any custom knowledge base, not just Wikipedia.

Cons:

  • Very heavy computationally; requires a GPU for reasonable inference times.
  • High memory requirements for loading the pre-trained models.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Load the ReBel model (seq2seq architecture)
model_name = "Babelscape/rebel-large"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

def extract_relations(text: str):
    """Use ReBel to jointly extract entities and relations."""
    # Tokenize input text
    inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)

    # Generate output sequence with beam search
    outputs = model.generate(
        inputs["input_ids"],
        max_length=256,
        num_beams=5,
        early_stopping=True
    )

    # Decode the generated triplet sequence
    decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
    triplets = []
    parts = decoded.split("<triplet>")
    for part in parts[1:]:
        try:
            subj, rest = part.split("<subj>")
            rel, obj = rest.split("<obj>")
            triplets.append({
                "subject": subj.strip(),
                "relation": rel.strip(),
                "object": obj.strip()
            })
        except ValueError:
            continue
    return triplets

text = "Punta Cana is a resort town in the Dominican Republic."
print(extract_relations(text))

Comparison of Solutions

To help you choose the right tool, here is a radar chart comparing the four solutions across five dimensions: Accuracy, Ease of Use, Speed, Customizability, and Maintenance.

Practical Case Study: Linking News Entities to a Knowledge Base

Let us walk through a practical scenario. Imagine you are building a news aggregation platform and need to extract Person and Organization entities from a news snippet, linking them to DBpedia to fetch additional structured data. For this case study, we will use the free DBpedia Spotlight API due to its zero-setup nature and excellent performance on general news text.

import requests

def link_news_entities(text):
    """
    Extracts and links person and organization entities from text
    using the free DBpedia Spotlight API.
    """
    # DBpedia Spotlight public API endpoint
    api_url = "https://api.dbpedia-spotlight.org/en/annotate"
    
    # Define parameters for the API request
    params = {
        "text": text,
        "confidence": 0.5,  # Minimum confidence score for linking
        "types": "DBpedia:Person,DBpedia:Organisation"  # Filter for specific entity types
    }
    
    # Request JSON response format
    headers = {
        "Accept": "application/json"
    }
    
    try:
        # Send GET request to the API
        response = requests.get(api_url, params=params, headers=headers)
        response.raise_for_status()  # Raise an exception for HTTP errors
        
        # Parse the JSON response
        data = response.json()
        resources = data.get("Resources", [])
        
        linked_entities = []
        for resource in resources:
            # Extract surface form (the text mention) and URI (the knowledge base link)
            surface_form = resource.get("@surfaceForm")
            uri = resource.get("@URI")
            entity_types = resource.get("@types")
            
            linked_entities.append({
                "mention": surface_form,
                "knowledge_base_uri": uri,
                "types": entity_types
            })
            
        return linked_entities
        
    except requests.exceptions.RequestException as e:
        print(f"API Request failed: {e}")
        return []

# Example news text
news_snippet = "Tim Cook announced that Apple will expand its operations in London next year."

# Execute the linking function
results = link_news_entities(news_snippet)

# Display the results
for entity in results:
    print(f"Mention: {entity['mention']}")
    print(f"URI: {entity['knowledge_base_uri']}")
    print(f"Types: {entity['types']}")
    print("-" * 40)

In this code, we send a news snippet about Tim Cook and Apple to the DBpedia Spotlight API. We filter the results specifically for DBpedia:Person and DBpedia:Organisation. The API successfully identifies "Tim Cook" and links him to his respective DBpedia URI, and maps "Apple" to the technology company rather than the fruit, demonstrating contextual disambiguation.

Using the APIShare Platform

While building your own Entity Linking pipeline or relying on public endpoints is a great start, production environments require stability, low latency, and high availability. Public free APIs often suffer from rate limits and downtime. This is where the APIShare platform becomes invaluable.

APIShare is a comprehensive API aggregation and management platform designed to help developers discover, test, and deploy APIs efficiently. If you want to integrate a reliable Entity Linking API without managing heavy infrastructure, you can explore the options available on the platform. To get started, you can visit apishare.cc/register to create your developer account.

Once registered, you can browse a wide variety of NLP and AI services. For developers specifically looking for no-cost options to prototype their applications, APIShare offers a dedicated section. You can check the available community and freemium models at apishare.cc/free-api. By utilizing these resources, you ensure your application remains scalable while avoiding the upfront costs of commercial enterprise APIs.

Furthermore, if your project scales beyond the free tier, APIShare makes it incredibly easy to upgrade your plan or switch to a different provider without changing your application's core architecture. Simply sign in at apishare.cc/register to manage your API keys, monitor usage analytics, and access detailed documentation. For continuous access to newly added free endpoints and community-driven NLP tools, keep an eye on apishare.cc/free-api.

import requests

# Your APIShare API key (replace with your actual key)
APISHARE_API_KEY = "your_api_key_here"

# Example: call an entity linking API hosted on APIShare
api_url = "https://api.apishare.cc/v1/entity-linking"

headers = {
    "Authorization": f"Bearer {APISHARE_API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "text": "Elon Musk founded SpaceX and leads Tesla as CEO.",
    "language": "en",
    "knowledge_base": "wikidata",
    "confidence_threshold": 0.5
}

response = requests.post(api_url, json=payload, headers=headers, timeout=30)
if response.status_code == 200:
    data = response.json()
    for entity in data.get("entities", []):
        print(f"Mention: {entity['mention']}, QID: {entity['qid']}, Score: {entity['score']:.3f}")
else:
    print(f"API call failed: {response.status_code} - {response.text}")

Summary

Entity Linking bridges the gap between unstructured text and structured knowledge, unlocking deeper semantic understanding for your applications. Whether you choose the pipeline-integrated SpaCy Entity Linker, the high-speed Wikipedia2Vec approach, the ready-to-use DBpedia Spotlight API, or the highly accurate BLINK/ReBel models, there is a free solution available for every technical requirement. By combining these tools with robust API management platforms like APIShare, developers can build sophisticated, knowledge-driven applications without incurring prohibitive costs. Evaluate your specific needs regarding accuracy, infrastructure, and latency to select the perfect Entity Linking solution for your next project.

More in this category

Free Text Summarization API Complete Tutorial: Condense Long Documents into Concise Summaries at Zero Cost (2026-11-11 Verified)Free Part-of-Speech (POS) Tagging API Complete Tutorial: Zero-Cost AI-Powered Grammar Category Labeling (Verified 2026-11-10)Free Named Entity Recognition (NER) API Complete Tutorial: Zero-Cost AI-Powered Person, Location & Organization Extraction (Verified 2026-11-09)Free Keyphrase Extraction API Complete Tutorial: Zero-Cost AI-Powered Article Keyword Discovery (Verified 2026-11-08)Free Dependency Parsing API Complete Tutorial

Ready to use free LLM APIs?

APIShare aggregates free AI APIs worldwide — sign up and get bonus credits.