SDKs overview
PatentsView provides programmatic access to its comprehensive patent data through a RESTful API, which can be interacted with directly via HTTP requests or through specialized Software Development Kits (SDKs) and community-contributed libraries. These tools are designed to streamline the process of querying, retrieving, and analyzing patent information, including details on patents, inventors, assignees, and geographic locations.
SDKs abstract the underlying API structure, handling aspects such as request construction, authentication (where applicable), response parsing, and error handling. This abstraction allows developers to focus on data utilization rather than on the mechanics of API interaction. While PatentsView offers official SDKs for popular data science languages like Python and R, the open nature of its API also permits the development of community-driven libraries in other programming environments.
The PatentsView API is well-documented, offering clear examples and specifications for its various endpoints, which facilitates both direct API calls and the development of custom client libraries. The API's design supports a range of queries, from simple keyword searches to complex aggregations, making it suitable for academic research, public policy analysis, and innovation trend identification, as outlined in the PatentsView official documentation.
Official SDKs by language
PatentsView maintains official SDKs primarily for languages popular in data science and statistical computing environments. These libraries are developed and supported by the PatentsView team to ensure compatibility and optimal performance with their API. The primary official SDKs are available for Python and R, reflecting the common tools used by their target audience of researchers and analysts.
| Language | Package Name | Installation Command | Maturity |
|---|---|---|---|
| Python | patentsview-api |
pip install patentsview-api |
Stable |
| R | patentsview |
install.packages("patentsview") |
Stable |
These official SDKs provide functions and methods that map directly to the PatentsView API endpoints, simplifying data retrieval. For instance, the Python library might offer functions like search_patents() or get_inventors(), which internally construct the appropriate API request and return parsed data structures. Similarly, the R package provides functions that integrate seamlessly into typical R data analysis workflows, often returning data frames.
Installation
Installing the PatentsView SDKs involves using the standard package managers for Python and R. These commands retrieve the latest stable version of the library from their respective repositories and make it available in your local development environment.
Python SDK Installation
To install the official Python SDK, patentsview-api, use the pip package installer. This command will download and install the library and its dependencies:
pip install patentsview-api
For users working in a virtual environment, activate the environment before running the installation command. Detailed instructions for managing Python packages can be found in the Python Packaging Authority documentation.
R SDK Installation
To install the official R SDK, patentsview, use the install.packages() function within your R environment or RStudio:
install.packages("patentsview")
This command fetches the package from CRAN (The Comprehensive R Archive Network) and installs it. After installation, the package can be loaded into your R session using library(patentsview) to make its functions available.
Quickstart example
The following quickstart examples demonstrate basic usage of the official Python and R SDKs to query the PatentsView API. These examples illustrate how to retrieve a small set of patent records, focusing on simplicity and ease of understanding.
Python Quickstart
This Python example uses the patentsview-api library to fetch the first five patents related to "artificial intelligence" and prints their titles and publication dates. The example assumes the library has been installed as described in the installation section.
from patentsview_api import PatentsViewAPI
# Initialize the API client
api = PatentsViewAPI()
# Define a query to search for patents with "artificial intelligence" in the title
query = {"_text_any": {"patent_title": "artificial intelligence"}}
# Fetch the first 5 patents matching the query
# The 'per_page' parameter limits the number of results per request
# The 'fields' parameter specifies which fields to return
response = api.search_patents(
query=query,
fields=["patent_id", "patent_title", "patent_date"],
per_page=5
)
# Process and print the results
if response and response.get('patents'):
print("Found patents:")
for patent in response['patents']:
print(f" ID: {patent.get('patent_id')}")
print(f" Title: {patent.get('patent_title')}")
print(f" Date: {patent.get('patent_date')}\n")
else:
print("No patents found or an error occurred.")
R Quickstart
This R example uses the patentsview package to perform a similar search, retrieving the first five patents related to "machine learning." The output is presented in a data frame format, which is typical for R data analysis workflows. This example assumes the package has been installed and loaded.
# Load the patentsview package
library(patentsview)
# Define a query to search for patents with "machine learning" in the title
# The query uses PatentsView API's JSON-like filter structure
query_r <- '{"_text_any": {"patent_title":"machine learning"}}'
# Fetch the first 5 patents matching the query
# The `query_patent()` function is used for patent searches
# `fields` specifies the columns to retrieve, and `per_page` limits results
patents_data <- query_patent(
query = query_r,
fields = c("patent_id", "patent_title", "patent_date"),
per_page = 5
)
# Print the results
if (!is.null(patents_data) && nrow(patents_data) > 0) {
cat("Found patents:\n")
print(patents_data)
} else {
cat("No patents found or an error occurred.\n")
}
Community libraries
In addition to the officially supported SDKs, the PatentsView API's open and well-documented nature has fostered the development of community-contributed libraries and wrappers. These libraries extend access to the PatentsView data ecosystem to a broader range of programming languages and platforms, catering to specific developer preferences or project requirements.
Community libraries are typically developed and maintained independently by their creators, often hosted on platforms like GitHub. While they may not carry the same level of official support as the PatentsView team's own SDKs, they can offer valuable functionality, language-specific idioms, or integrations with other tools. Developers considering a community library should review its documentation, community activity, and maintenance status to ensure it meets their project's needs.
Examples of potential community contributions could include:
- JavaScript/Node.js wrappers: For front-end or server-side applications requiring direct API calls, abstracting fetch requests and JSON handling.
- Java/C# clients: For enterprise applications built on these platforms, providing strongly typed interfaces to the API.
- Go/Rust clients: For high-performance or concurrent data processing tasks, leveraging the strengths of these languages.
Developers are encouraged to explore community repositories or package managers for their preferred language to discover available libraries. For those interested in contributing, the Mozilla Developer Network's guide on the Fetch API provides a foundational understanding of how web APIs are consumed, which can be useful for building custom clients.