SerpBase
Back to Blog

Google filetype Search API: Find PDFs and Spreadsheets as JSON

Put filetype:pdf or filetype:xlsx in a Google search request to get documents only. Phone and desktop compared, with a filter that keeps real file links.

November 30, 2026
By SerpBase Team2 min read

Short answer: put filetype:pdf in the q of a /google/search request. Google then returns documents of that type, and each result's url ends in .pdf. Use the default phone layout: in our test every result was a document, while the desktop layout mixed in a video and a book page.

The request

curl -X POST 'https://api.serpbase.dev/google/search' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{"q":"climate change annual report filetype:pdf","gl":"us","hl":"en"}'

No extra parameter and no extra charge: the operator is part of the query string, exactly as you would type it into Google.

What came back

Run on 30 November 2026, the phone layout (the default) returned 10 organic results, all reports from government and research bodies. The first three (shortened):

"organic": [
  {
    "rank": 1,
    "title": "2025 Annual Report - Maryland Commission on Climate Change",
    "url": "https://mde.maryland.gov/.../MCCC_Annual_Report_2025.pdf",
    "display_link": "https://mde.maryland.gov"
  },
  {
    "rank": 2,
    "title": "Annual Report",
    "url": "https://www.climatechangeauthority.gov.au/.../ClimateChangeAuthorityAnnualReport2023-24.pdf",
    "display_link": "https://www.climatechangeauthority.gov.au"
  },
  {
    "rank": 3,
    "title": "CLIMATE CHANGE 2023",
    "url": "https://www.ipcc.ch/report/ar6/syr/downloads/report/IPCC_AR6_SYR_SPM.pdf",
    "display_link": "https://www.ipcc.ch"
  }
]

The rest came from the WMO library, the UNFCCC, Columbia Law School, New Zealand's Climate Change Commission and others.

The same query with "device":"desktop" reported "About 88 results". Its first two were PDFs, but rank 3 was a YouTube video and rank 9 a Google Books page. Google interprets the operator a little more loosely on desktop, so if you need documents only, stay on the phone layout and check the extension.

Keep only real documents

import requests

data = requests.post("https://api.serpbase.dev/google/search",
                     headers={"X-API-Key": "YOUR_API_KEY"},
                     json={"q": "climate change annual report filetype:pdf",
                           "gl": "us", "hl": "en"},
                     timeout=60).json()

pdfs = [o for o in data.get("organic", [])
        if o.get("url", "").lower().split("?")[0].endswith(".pdf")]
for o in pdfs:
    print(o["rank"], o["title"], o["url"])
print(len(pdfs), "of", len(data.get("organic", [])), "results are PDF links")

When a result's url is a google.com/goto link instead of the file itself, display_link still shows the site; open the link to reach the document.

Other file types

Swap the extension. us population by state filetype:xlsx returned 10 spreadsheets on the same day, every title starting with Google's [XLS] label and the first one from www2.census.gov.

Things that trip people up

  • No space after the colon. filetype: pdf is read as two ordinary words.
  • Desktop is looser. In our test 2 of the first 3 desktop results were PDFs, against 3 of 3 on the phone layout.
  • Counts are estimates. "About 88 results" is Google's rounding, not a total you can page through.

Related

Searching inside titles: Google intitle search API. Auditing a site's pages: site: query audits. Saving results to a spreadsheet: export Google results to CSV.

Cost and docs

Google searches are 1 credit. Credits cost $0.25–$0.50 per 1,000 depending on the plan; new accounts get 500 free credits.