DEV Community

carrierone
carrierone

Posted on

USPTO Patent and Trademark Data via REST API

USPTO Patent and Trademark Data via REST API

For developers building tools that require patent search functionality, accessing data from the United States Patent and Trademark Office (USPTO) can be a valuable resource. The USPTO offers a RESTful API where one can query patents based on various criteria such as keyword, inventor, or assignee.

To get started with fetching patent data via this API, here's a small Python code example that uses the requests library to search for patents containing a specific keyword:

import requests

def search_patents(keyword):
    url = "https://api.verilexdata.com/api/v1/patents/sample"
    params = {
        'q': f'"{keyword}"',  # Search using double quotes around the keyword
        'format': 'json'
    }

    response = requests.get(url, params=params)
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Failed to fetch patents: {response.status_code}")

# Example usage
keyword = "artificial intelligence"
patents_data = search_patents(keyword)
print(patents_data)
Enter fullscreen mode Exit fullscreen mode

This code snippet searches for patents containing the keyword "artificial intelligence". It constructs a URL with the appropriate query parameters and sends a GET request. If the response status is 2

Top comments (0)