Free Knowledge Graph Construction API Tutorial: Zero-Cost Entity-Relation Network Mining from Text (2026-10-17 Verified)
This article is curated by apishare.cc. All examples were verified on October 17, 2026. For more free API recommendations, visit the apishare.cc Free API Directory or English Tutorial Library.
Introduction
Knowledge graphs have become the backbone of modern semantic search, recommendation systems, and enterprise data integration. However, building a knowledge graph from raw text traditionally requires expensive NLP infrastructure, annotated training data, and substantial compute budgets. In 2026, the landscape has shifted: a growing ecosystem of free APIs and open-source models now enables developers to extract entities and relations from text at zero cost, at least for prototyping and small-scale production workloads.
This tutorial benchmarks five free knowledge graph construction solutions that we verified on October 17, 2026. Each solution covers a different layer of the knowledge graph stack: zero-shot NER, entity linking to a public knowledge base, cloud-based MLaaS, self-hosted NLP pipelines, and structured entity querying via SPARQL. For every option, you will find a feature table, integration steps, a Python code snippet, and a recommended use case. We close with an ECharts radar comparison and a decision tree to help you choose the right tool for your project.
If you want to discover more zero-cost endpoints beyond this list, browse the apishare.cc Free API Directory, which is updated weekly by the community.
Solution 1: Hugging Face Inference API with GLiNER (Zero-Shot NER)
GLiNER is a transformer-based model that performs named entity recognition without requiring task-specific training. You simply pass a list of candidate labels and the model extracts matching spans from arbitrary text. Combined with the Hugging Face Inference API, you can run GLiNER without provisioning any GPU.
Feature Table
| Feature | Value |
|---|---|
| Provider | Hugging Face |
| Model | GLiNER (zero-shot NER) |
| Free Quota | Generous monthly inference budget for signed-in users |
| Output | Entity spans + labels |
| Relation Extraction | Not native (pair with RE model) |
| Auth | Bearer token |
| Latency | 300-800 ms typical |
Integration Steps
- Create a Hugging Face account and generate a read access token.
- Install the
huggingface_hubPython package. - Call the Inference API with your text and candidate labels.
- Post-process spans into nodes; optionally chain a relation-extraction model for edges.
Python Example
import requests, os
HF_TOKEN = os.getenv("HF_TOKEN")
API_URL = "https://api-inference.huggingface.co/models/knowledgator/gliner-multitask-v1.0"
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
payload = {
"inputs": "Apple was founded by Steve Jobs in Cupertino in 1976.",
"parameters": {
"labels": ["ORG", "PERSON", "LOCATION", "DATE"]
}
}
resp = requests.post(API_URL, headers=headers, json=payload)
entities = resp.json()
for ent in entities:
print(ent["label"], "->", ent["text"])
Use Case
Best for rapid prototyping of domain-specific knowledge graphs where you cannot afford annotation time. For example, extracting custom entity types like "DRUG", "DISEASE", and "GENE" from biomedical abstracts without fine-tuning.
Solution 2: DBpedia Spotlight (Entity Linking + Public Knowledge Base)
DBpedia Spotlight links mentions in your text to DBpedia URIs, instantly grounding entities in a public LOD knowledge base. This gives you not only entity recognition but also rich structured metadata for each node.
Feature Table
| Feature | Value |
|---|---|
| Provider | DBpedia Association |
| Endpoint | Public REST + Docker image |
| Free Quota | Unlimited on public instance (rate-limited) |
| Output | Surface form + DBpedia URI + types |
| Knowledge Base | DBpedia (Wikipedia-derived) |
| Confidence | Configurable via confidence and support params |
Integration Steps
- POST your text to the public Spotlight endpoint.
- Parse the returned JSON for Resources containing URI, surfaceForm, and types.
- Use the URIs to fetch additional properties via DBpedia SPARQL.
- Build edges by co-occurrence within the same sentence or document.
Python Example
import requests
text = "Albert Einstein published the theory of relativity in 1915."
url = "https://api.dbpedia-spotlight.org/en/annotate"
params = {"text": text, "confidence": 0.5, "support": 10}
resp = requests.get(url, params=params, headers={"Accept": "application/json"})
data = resp.json()
for res in data.get("Resources", []):
print(res["@surfaceForm"], "->", res["@URI"], "| types:", res["@types"])
Use Case
Ideal for academic datasets and open-data projects that benefit from linking to Wikipedia-derived entities. Commonly used in digital humanities, journalism fact-checking, and LOD publishing.
Solution 3: Google Cloud Natural Language API (Free Tier 5000 Units/Month)
Google Cloud Natural Language API offers entity analysis, sentiment, syntax, and content classification in a single endpoint. The free tier grants 5,000 units per month, which is sufficient for medium-scale text mining.
Feature Table
| Feature | Value |
|---|---|
| Provider | Google Cloud |
| Free Tier | 5,000 units/month |
| Output | Entities + salience + metadata + Wikipedia URLs |
| Languages | 100+ |
| Auth | Service account JSON |
| Latency | 150-400 ms |
Integration Steps
- Create a GCP project and enable the Natural Language API.
- Create a service account and download the JSON key.
- Install
google-cloud-language. - Call
analyze_entitiesand convert results to graph nodes/edges.
Python Example
from google.cloud import language_v1
client = language_v1.LanguageServiceClient()
document = language_v1.Document(
content="Tesla announced a new Gigafactory in Berlin in 2021.",
type_=language_v1.Document.Type.PLAIN_TEXT
)
response = client.analyze_entities(document=document)
for entity in response.entities:
print(entity.name, "| type:", entity.type_.name,
"| salience:", round(entity.salience, 3),
"| wiki:", entity.metadata.get("wikipedia_url", ""))
Use Case
Best for commercial pilots where you need enterprise-grade SLAs, multilingual support, and built-in salience scoring for ranking entity importance in the graph.
Solution 4: spaCy Self-Hosted Pipeline (NER + Relation Extraction)
spaCy is the de facto open-source NLP library for production. By combining en_core_web_trf with a relation-extraction component (such as rel_component from spaCy projects), you can run an entire knowledge graph pipeline on your own infrastructure with no per-call cost.
Feature Table
| Feature | Value |
|---|---|
| Provider | Explosion / Open Source |
| License | MIT |
| Models | en_core_web_sm / md / lg / trf |
| Relation Extraction | Custom trainable component |
| Cost | Free (compute only) |
| Privacy | Full on-premise |
Integration Steps
pip install spacyand download a model.- Run the NER pipeline on your documents.
- Add a relation-extraction component trained on a small labeled set (or use zero-shot RE models).
- Export nodes and edges to Neo4j, NetworkX, or CSV.
Python Example
import spacy
nlp = spacy.load("en_core_web_trf")
doc = nlp("Tim Cook is the CEO of Apple, headquartered in Cupertino.")
nodes = set()
edges = []
for ent in doc.ents:
nodes.add((ent.text, ent.label_))
persons = [e for e in doc.ents if e.label_ == "PERSON"]
orgs = [e for e in doc.ents if e.label_ == "ORG"]
for p in persons:
for o in orgs:
edges.append((p.text, "WORKS_AT", o.text))
print("Nodes:", nodes)
print("Edges:", edges)
Use Case
Perfect for privacy-sensitive domains (healthcare, legal, finance) where text cannot leave your infrastructure, and for teams that need full control over model weights and training data.
Solution 5: Wikidata API (Entity Query + SPARQL)
Wikidata is the largest open knowledge base, with over 100 million items. The Wikidata API and SPARQL endpoint let you query entities, properties, and relations directly, making it an excellent backbone for enriching your graph.
Feature Table
| Feature | Value |
|---|---|
| Provider | Wikimedia Foundation |
| Endpoint | wbgetentities + Query Service |
| Free Quota | Unlimited (fair use) |
| Output | Items, properties, claims, sitelinks |
| Query Language | SPARQL 1.1 |
| Auth | None (User-Agent recommended) |
Integration Steps
- Search for items using
wbsearchentities. - Fetch full entity data with
wbgetentities. - Run SPARQL queries for complex relation patterns.
- Merge results with entities extracted from your corpus.
Python Example
import requests
S = requests.Session()
S.headers.update({"User-Agent": "KG-Tutorial/1.0 (research@example.org)"})
search_url = "https://www.wikidata.org/w/api.php"
params = {
"action": "wbsearchentities",
"search": "Albert Einstein",
"language": "en",
"format": "json",
"limit": 1
}
data = S.get(search_url, params=params).json()
qid = data["search"][0]["id"]
print("Wikidata QID:", qid)
sparql_url = "https://query.wikidata.org/sparql"
query = """
SELECT ?occupationLabel WHERE {
wd:%s wdt:P106 ?occupation .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
""" % qid
r = S.get(sparql_url, params={"query": query},
headers={"Accept": "application/sparql-results+json"})
for row in r.json()["results"]["bindings"]:
print("Occupation:", row["occupationLabel"]["value"])
Use Case
Best for enriching your graph with canonical identifiers (QIDs), cross-lingual labels, and structured relations sourced from a community-maintained knowledge base.
ECharts Radar Comparison
The following radar chart scores each solution across six dimensions: Free Quota, Model Capability, Ease of Integration, Accuracy, Latency, and Commercial Use. Scores are normalized to a 0-10 scale based on tests conducted on 2026-10-17.
Decision Tree
Use the following decision tree to select the right solution for your scenario:
-
Do you need to process sensitive data on-premise?
- Yes -> spaCy Self-Hosted Pipeline (Solution 4)
- No -> continue
-
Do you need to link entities to a public knowledge base (Wikipedia/DBpedia/Wikidata)?
- Yes, Wikipedia/DBpedia -> DBpedia Spotlight (Solution 2)
- Yes, Wikidata QIDs -> Wikidata API (Solution 5)
- No -> continue
-
Do you need enterprise SLA and multilingual support in production?
- Yes -> Google Cloud Natural Language API (Solution 3)
- No -> continue
-
Do you need custom entity types without labeled training data?
- Yes -> Hugging Face GLiNER (Solution 1)
- No -> spaCy with a pre-trained model is sufficient (Solution 4)
Hybrid Recommendation
For most real-world knowledge graph projects, a hybrid pipeline delivers the best results:
- Use GLiNER for zero-shot entity extraction on raw text.
- Use DBpedia Spotlight or Wikidata API to link and enrich entities.
- Use spaCy for relation extraction and on-premise processing.
- Use Google Cloud NL as a fallback for multilingual content.
This layered approach maximizes coverage while keeping costs near zero. You can discover additional free endpoints to extend this pipeline in the apishare.cc Free API Directory.
Conclusion
Building a knowledge graph no longer requires a six-figure NLP budget. As verified on October 17, 2026, the five solutions covered in this tutorial let you extract entities and relations from text for free, each excelling in a different dimension:
- Hugging Face GLiNER wins on flexibility and zero-shot capability.
- DBpedia Spotlight wins on instant entity linking to LOD.
- Google Cloud NL wins on accuracy and enterprise readiness.
- spaCy wins on privacy and full model control.
- Wikidata API wins on enrichment and canonical identifiers.
If you are ready to build your own knowledge graph pipeline, start by registering an account on apishare.cc to access curated API keys, usage analytics, and community-maintained examples:
For ongoing updates on free APIs for NLP, search, and graph databases, bookmark the apishare.cc Free API Directory and revisit this tutorial as the ecosystem evolves. Happy graph building!