> ## Content Index
> Fetch the complete content index at: https://serpapi.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to find the Google Knowledge Graph ID (kgmid) for anything
- URL: https://serpapi.com/blog/how-to-find-google-knowledge-graph-id-kgmid/
- Published: 2026-07-15T18:49:15.000Z
- Updated: 2026-08-04T10:25:29.000Z
- Description: Google's Knowledge Graph is powered by an extensive database of IDs. Here's how to find them for any person, place, or thing.
- Author: Corbin Davenport
- Tags: google search, sport

When you search for a person, place, movie, TV show, city, or other topic with Google Search, you might get a card the top of the page with organized details. For movie searches, the card might contain ratings, where to watch it, the release date, the genre, and other information. That's called the [Knowledge Graph](https://support.google.com/knowledgepanel/answer/9787176?hl=en), with a Knowledge Graph ID (kgmid) assigned to each item.

Here's how to find the Knowledge Graph ID for anything that Google has identified, either manually or programmatically, with some additional information about how the IDs are organized.

## How the Knowledge Graph ID (kgmid) works

Every person, place, or thing that Google can identify has a Knowledge Graph ID. It's a bit like [ISBN numbers](https://en.wikipedia.org/wiki/ISBN) for books or [ISMN numbers](https://en.wikipedia.org/wiki/International%5FStandard%5FMusic%5FNumber) for music releases, but not restricted to any certain category, and (usually) not something a person would ever directly read.

![Google search for Canada, with pictures, a "Country in North America" label, the capital, and other information at the top of the page.](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-21.png)

The country of Canada has a Knowledge Graph with an ID of `/m/0d060g`.

These IDs help Google organize different topics, even if they have similar or identical names. [Apple the fruit](https://www.google.com/search?kgmid=/m/014j1m) has a different ID than [Apple the tech company](https://www.google.com/search?kgmid=/m/0k8z). The name "Superman" matches the [comic book character](https://www.google.com/search?kgmid=/m/070vn), the [1978 film](https://www.google.com/search?kgmid=/m/01%5Fmdl) with Christopher Reeve, the [2025 film](https://www.google.com/search?kgmid=/g/11k9l3fmd9) with David Corenswet, the [song by Eminem](https://www.google.com/search?kgmid=/g/11s9h89nxf), and the [theme song for *Scrubs*](https://www.google.com/search?kgmid=%2Fg%2F11fltvsz8s)by Lazlo Bane, but they all have different IDs.

If you have the Knowledge Graph ID for a given topic, you can use it to look up all available details for that topic using SerpApi's Google APIs, [Google's enterprise cloud APIs](https://docs.cloud.google.com/enterprise-knowledge-graph/docs/overview) (which also use [Machine IDs](https://docs.cloud.google.com/enterprise-knowledge-graph/docs/mid) in addition to Graph IDs), and other services. For example, once you know the Knowledge Graph ID for a football team, you can check its current and upcoming games on a regular basis with the [SerpApi Google Sports Results API](https://serpapi.com/sports-results).

The database for Knowledge Graph is actually *two* databases: the legacy list from [Freebase](https://en.wikipedia.org/wiki/Freebase%5F%28database%29) where items (usually) have a `/m/` prefix, and the modern Knowledge Graph where items have a `/g/` prefix. That's why older topics tend to start with `/m/`, as their entries were created before the modern Knowledge Graph.

## How to find the Knowledge Graph ID (kgmid)

There are a few ways to find the Knowledge Graph ID for a given person, place, or thing.

### Find the ID from Google Search

The first option for finding a Knowledge Graph ID is from Google's own search results. If a card (or just the title) appears for a search result, click the three-dot menu next to the title, then click the Share menu option.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-22.png)

This will give you a `share.google` URL, which is a shortlink that redirects to the full URL containing the Knowledge Graph ID. You need to open that link in your web browser, and then the ID will be in the address bar as the text between `kgmid=` and `&` strings, like `/m/05qtj` in this example:

```url
https://www.google.com/search?kgmid=/m/05qtj&hl=en-US&q=Paris&she...
```

The ID might be in URL-encoded format, like `%2Fm%2F04jpl` in this example:

```url
https://www.google.com/search?kgmid=%2Fm%2F04jpl&hl=en-US&q=London&she...
```

For those encoded strings, a [URL decode tool](https://www.w3schools.com/tools/tool%5Furl%5Fencoder.php) can give you the original form, or you can run `decodeURIComponent("put-the-id-here")` in [your browser's JavaScript console](https://developer.chrome.com/docs/devtools/console/javascript/).

You can also fetch the `share.google` link with [cURL](https://serpapi.com/blog/web-scraping-with-curl-fetching-raw-html-data/), set it to follow the first redirect, and look for the `kgmid` parameter in the final location:

```shell
curl -iL --max-redirs 1 https://share.google/examplelink
```

**Some pages on Google Search can have two Knowledge Graph IDs.** For example, if you [search for "recent nfl games"](https://www.google.com/search?q=nba+games+recent) and click the "See more" button with the arrow icon, it opens a new page using data from two Knowledge Graph topics.

![Screenshot of recent NFL games on Google](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-24.png)

The full page for recent NFL games on Google.

These pages will have the Knowledge Graph IDs in the `#sie` section of the URL, instead of a `kgmid` parameter:

```url
https://www.google.com/search?q=recent+nfl+games&sca_esv=b3f...&sclient=gws-wiz-serp#sie=lg;/g/11lyp42zk1;6;/m/059yj;mt;fp;1;;;;-1
```

In this example, the first ID is `/g/11lyp42zk1` and represents the 2025 NFL season, while the second ID is `/m/059yj` and represents the NFL organization. If you're not sure which ID is for which topic, read [the section on checking IDs](#how-to-check-a-knowledge-graph-id).

For league/tournament pages, the first ID is the current season, and the second ID is the league. For sports teams, the first ID is the team, and the second is the current league/tournament season. For sports games, the first ID is the individual game, and the second ID is the league.

### Find the ID with Wikidata

[Wikidata](https://www.wikidata.org/wiki/Wikidata:Main%5FPage) is a collaborative knowledge database with over 100 million items, and each item *usually* includes a linked Google Knowledge Graph ID. Wikidata is one of the main information sources for Google's Knowledge Graph services, and some of its data originated from the [Google-owned Freebase](https://en.wikipedia.org/wiki/Freebase%5F%28database%29), which shut down in 2015.

You can [start a search](https://www.wikidata.org/wiki/Special:Search) on Wikidata to check if a matching result is available. The number in parentheses for each item is the Wikidata number, not a Knowledge Graph ID.

![Screenshot of Wikidata](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-25.png)

Wikidata search for "London."

From the search results, select the page for the topic you want, and look for either a "Google Knowledge Graph ID" or "Freebase ID" on the page.

![Wikidata screenshot](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-26.png)

London has a Freebase ID of `/m/04jpl`.

![Wikidata screenshot](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-27.png)

The 2026 FIFA World Cup has a Google Knowledge Graph ID of `/g/1pznmpnqh`.

You can also use the [Wikidata Query Service](https://www.wikidata.org/wiki/Wikidata:SPARQL%5Fquery%5Fservice/Wikidata%5FQuery%5FHelp) to programmatically fetch the IDs for a given topic or item.

### Find the ID with SerpApi

Finally, you can use the [Google Search Engine Results API](https://serpapi.com/search-api) from SerpApi to obtain a Knowledge Graph ID from a text search. If you don't have one already, you need to [create an account](https://serpapi.com/users/sign%5Fup) and verify your email and other details. After that, get the API key from [your account dashboard](https://serpapi.com/manage-api-key).

First, if you [perform a search with the SerpApi Playground](https://serpapi.com/playground?q=Paris&location=Austin%2C+Texas%2C+United+States&gl=us&hl=en) in your web browser, the JSON results include `kgmid` values. They might be under the `knowledge_graph` object.

![Playground screenshot for a Google Search for Paris.](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-28.png)

SerpApi Playground will show any `kgmid` values in the JSON preview.

For sports-related topics, the values can be in the `sports_results` object. The query ["recent NFL games" in Playground](https://serpapi.com/playground?q=recent+nfl+games&location=Austin%2C+Texas%2C+United+States&gl=us&hl=en) includes an ID for each team, game, and stadium/location.

![Playground screenshot for a Google Search for recent NFL games.](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-29.png)

More `kgmid` and `venue_kgmid` values in the SerpApi Playground.

You can also programmatically fetch the main `kgmid` value for a search, using any of [SerpApi's official integrations](https://serpapi.com/integrations). Here's how to find the `kgmid` for London using simple GET request, combined with the [JSON Restrictor feature](https://serpapi.com/json-restrictor):

```url
https://serpapi.com/search.json?engine=google&q=london&gl=us&json_restrictor=knowledge_graph.kgmid&api_key=YOUR_KEY_GOES_HERE
```

Here's the same search in a Python script, using the [official SerpApi Python library](https://serpapi.com/integrations/python):

```
import serpapi
client = serpapi.Client(api_key=YOUR_KEY_GOES_HERE)

response = client.search({
  "engine": "google",
  "q": "london"
})

if response.get("knowledge_graph", {}).get("kgmid", {}):
  print(f"Found ID: {response['knowledge_graph']['kgmid']}")
else:
  print("No ID found!")
```

This is the search in Ruby, with the [official Ruby gem](https://serpapi.com/integrations/ruby) installed:

```ruby
require "serpapi"

response = SerpApi::Client.new(
  engine: "google",
  q: "london",
  api_key: YOUR_KEY_GOES_HERE
)

if response.search.dig(:knowledge_graph, :kgmid)
  puts "Found ID: #{response.search[:knowledge_graph][:kgmid]}"
else
  puts "No ID found!"
end
```

Finally, here's the search in Node.js with the [SerpApi JavaScript library](https://serpapi.com/integrations/javascript):

```javascript
import { getJson } from 'serpapi';

const search = await getJson({
  engine: "google",
  q: "london",
  api_key: YOUR_KEY_GOES_HERE
});

if (search?.knowledge_graph?.kgmid) {
  console.log(`Found ID: ${search.knowledge_graph.kgmid}`);
} else {
  console.log("No ID found!")
}
```

You can also make API requests with SerpApi with [Make.com](https://serpapi.com/blog/announcing-serpapis-make-app/), [N8N](https://serpapi.com/blog/boost-your-n8n-workflows-with-serpapis-verified-node/), and other low-code tools. If you need help, please [contact us](https://serpapi.com/#contact).

## How to check a Knowledge Graph ID

If you already have a Knowledge Graph ID and you need to check what it represents, there are a few ways to do that.

First, you can try using it in a Google Search by placing the `kgmid` in the URL, like this ID for New York City:

```url
https://www.google.com/search?kgmid=/m/02_286
```

The resulting search page should contain a Knowledge Graph card. The text in the search bar will also be filled by the topic's title. This works because `kgmid` is one of Google's URL parameters and can override the `q` query parameter. You can see how it fits alongside the others in our [guide to Google search parameters](https://serpapi.com/blog/google-search-parameters/).

![Google search results for New York City.](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/07/image-30.png)

A Google web search using a `kgmid` value instead of a `q` text search.

That method doesn't always work, but you can also try searching the ID on the [Wikidata website](https://www.wikidata.org/wiki/Special:Search), [Wikidata Query Service](https://www.wikidata.org/wiki/Wikidata:SPARQL%5Fquery%5Fservice/Wikidata%5FQuery%5FHelp), or [Google Knowledge Graph Search API](https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api). For sports topics, try the [Google Sports API Playground](https://serpapi.com/playground?engine=google%5Fsports) from SerpApi.