IP Street

IP Street Developer Hub

IP Street helps you integrate powerful conceptual patent search and claim text analytics directly into your application without the need to manage complicated and expensive back end infrastructure and data pipelines.

Documentation    Announcements

"Hello World!"

Code Examples of IP Street API Calls

Example code to get you up and running. These scripts can be can be git cloned from https://github.com/IPStreet/HelloWorld

from IPStreet import client, query

apikey = 'YourAPIKey'
api_version = 2

# Instantiate a Client
client = client.Client(apikey=apikey, api_version=api_version)

# Instantiate a Query
basic_data_query = query.PatentData()

#Add Parameters to your Query
basic_data_query.add_ultimate_parent('Tesla Motors, Inc.')
basic_data_query.add_end_date('2016-01-01', 'application_date')
basic_data_query.add_keywords('battery')
basic_data_query.add_max_expected_results(200)
basic_data_query.add_page_size(100)

# Send your Query with the Client
results = client.send(basic_data_query)

# Print each returned patent asset
for assets in results:
  print(assets)
library(httr)

# Utilities for getting results into data frames
ResultsToNewDataframe <- function(results){
  # Loop over content of response, making each a row in your data frame
  patents <-do.call("rbind", content(results)$Assets)
  
  return(as.data.frame(patents)) 
}

ResultsToExistingDataframe <- function(results, existing.data.frame){
  # Append new set of results to an existing data frame of results
  new.data.frame <-ResultsToNewDataframe(results)
  updated.data.frame <- rbind(existing.data.frame,new.data.frame)
  
  
  return(updated.data.frame) 
}

# Example IP Street API calls
SearchByOwner <- function(owner, page.number, api.key){
  r = POST(url = 'https://api.ipstreet.com/v2/data/patent',
           add_headers(`x-api-key` = api.key),
           body = list(q= list(owner = owner, page.number = page.number)),
           encode ="json")
  return(r)
}


GetFirstFourPages <- function(owner, api.key){
  # makes the first request
  r = SearchByOwner(owner = owner, page.number = 1, api.key = api.key)
  
  # create new data frame for results
  patents = ResultsToNewDataframe(r)
  
  # make additional calls for each page
  for (i in 2:4){
    r = SearchByOwner(owner = owner, page.number = i, api.key = api.key)
    #append results to data frame
    patents <- ResultsToExistingDataframe(r,patents)
  }
  return(patents)
}


# Begin program run 
api.key = 'Live_API_Key'

r = SearchByOwner(owner = "microsoft", page.number = 1, api.key = api.key)
single.page.results = ResultsToNewDataframe(r)


first.four.pages.results = GetFirstFourPages(owner = "microsoft", api.key = api.key)


search_by_owner() {
    # If you have an API key, you can use this method to search for all patents owned by a given company.
    # The method takes an owner name input and page number, returns target page of results from /data/patent

    endpoint="https://api.ipstreet.com/v1/data/patent"

    apiKey="x-api-key:PUT-YOUR-API-KEY-HERE"
    contentType="Content-Type:application/json"

    payload="{'q':{'owner':$1,'offset':$2}}"
    
    r="curl $endpoint -X POST -H $apiKey -H $contentType -d $payload"
    RESPONSE=`$r`

    # returning response
    echo "$RESPONSE"
}

# search_by_owner 'Microsoft' 1

get_all_pages() {
    # When you want to get all the results of your query, you must loop over all the pages in the given results set
    # This method returns all the results of search_by_owner() method above

    # #first call to get to total_asset_count, insert records to DB
    response=$( search_by_owner $1 1 )

    echo "$response"
    # set total page count
    # Doing some hack to retrieve totalPage value from json response.
    total_page_count=$(echo "$response"| grep -Eo '"totalPage": .*?[^\\]"'| awk '{print $2}'| tr -d '"')

    # follow-on searches to fill data set
    # current_page_count=2  # start at page 2
    for (( current_page_count=2; current_page_count<total_page_count; current_page_count++ ))
    do
        response=$( search_by_owner $1 $current_page_count )
        
        echo "$response"

        # perform an insert each record into your database here
        echo "$current_page_count pages received"
    done
    echo "$current_page_count total pages received"
}

#########################################
# Uncomment Below to Run Desired function
#########################################

# get just first page of results, print to console
# search_by_owner 'microsoft' 1

# get all results for owner=microsoft, print to console
# get_all_pages 'microsoft'


"Hello World!"

Code Examples of IP Street API Calls