patentgrepDocs

Getting started

Authentication

Every request needs your API key. Send it in the X-Api-Key header, the same header PatentsView uses. Authorization: Bearer <key> works too.

HeaderValue
X-Api-KeyYour key. Use this one; it matches PatentsView.
AuthorizationBearer followed by a space and your key.

Both headers work on every route, including the PatentsView-compatible endpoints. A PatentsView key won't work here: ask for a patentgrep key in the Quickstart.

curl -G https://api.patentgrep.com/v1/search \
  -H "X-Api-Key: $PATENTGREP_KEY" \
  --data-urlencode "q=solid electrolyte"
import os, requests

resp = requests.get(
    "https://api.patentgrep.com/v1/search",
    headers={"X-Api-Key": os.environ["PATENTGREP_KEY"]},
    params={"q": "solid electrolyte"},
)
resp.raise_for_status()
data = resp.json()
print(data)
const params = new URLSearchParams({
  q: "solid electrolyte",
});
const res = await fetch(`https://api.patentgrep.com/v1/search?${params}`, {
  headers: {
    "X-Api-Key": process.env.PATENTGREP_KEY,
  },
});
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
const data = await res.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
)

func main() {
	params := url.Values{}
	params.Add("q", "solid electrolyte")

	req, err := http.NewRequest(http.MethodGet, "https://api.patentgrep.com/v1/search?"+params.Encode(), nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("X-Api-Key", os.Getenv("PATENTGREP_KEY"))

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	data, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}
	if res.StatusCode != http.StatusOK {
		panic(fmt.Sprintf("%s: %s", res.Status, data))
	}
	fmt.Println(string(data))
}
require "json"
require "net/http"

uri = URI("https://api.patentgrep.com/v1/search")
uri.query = URI.encode_www_form(q: "solid electrolyte")

req = Net::HTTP::Get.new(uri)
req["X-Api-Key"] = ENV.fetch("PATENTGREP_KEY")

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
raise "#{res.code}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
data = JSON.parse(res.body)
p data
Bearer token
curl -G https://api.patentgrep.com/v1/search \
  -H "Authorization: Bearer $PATENTGREP_KEY" \
  --data-urlencode "q=solid electrolyte"

Keep your key secret

  • Call the API from your server, a script or an agent's tool, never from code that runs in a visitor's browser.
  • Read the key from an environment variable or a secret store, not from source control.
  • If a key leaks, reply to the email it came in and we'll replace it.
.env
# Loaded by your app, never committed
PATENTGREP_KEY=paste-your-key-here

Missing or wrong key

Without a valid key the API answers 401 with a sentence in detail. Check that the header name is spelled exactly and that the key has no spaces or line breaks around it.

401 Unauthorized401
{
  "detail": "Missing or wrong API token. Send it as `Authorization: Bearer <token>`."
}