Recipes: Four programs that your assistant can run with execute, and tips for programs of your own. # Recipes > Four programs that your assistant can run with execute, and tips for programs of your own. Each program runs as written in `execute`. They are plain JavaScript with top-level `await` and `return`, and the repository tests each one. ## An applicant’s recent patents `odp.patents.search` with `q`, `filters`, `rangeFilters`, `sort`, `fields`, and `facets`. ```js // Patent File Wrapper: an applicant's recent granted utility patents, newest // first, with only the fields needed (full records are large), plus a status // breakdown via facets. const applicant = 'PolyPlus Battery Company'; const r = await odp.patents.search({ q: `applicationMetaData.firstApplicantName:"${applicant}"`, filters: { 'applicationMetaData.applicationTypeLabelName': 'Utility' }, rangeFilters: { 'applicationMetaData.grantDate': ['2020-01-01', '2026-12-31'], }, sort: 'applicationMetaData.grantDate desc', fields: [ 'applicationNumberText', 'applicationMetaData.inventionTitle', 'applicationMetaData.patentNumber', 'applicationMetaData.grantDate', 'applicationMetaData.applicationStatusDescriptionText', ], facets: ['applicationMetaData.applicationStatusDescriptionText'], limit: 25, }); return { total: r.count, patents: (r.patentFileWrapperDataBag ?? []).map((p) => ({ application: p.applicationNumberText, patent: p.applicationMetaData?.patentNumber, granted: p.applicationMetaData?.grantDate, title: p.applicationMetaData?.inventionTitle, })), byStatus: r.facets, }; ``` ## PTAB challenges against a patent Every trial filed against one patent, then the decisions in the first trial. ```js // PTAB: every AIA trial (IPR/PGR/CBM) filed against one patent, then the // decisions in the first trial. Calls run one at a time per API key, so keep // the fan-out small. const patentNumber = '10169987'; const trials = await odp.ptab.proceedings.search({ q: `patentOwnerData.patentNumber:${patentNumber}`, fields: [ 'trialNumber', 'trialMetaData.trialTypeCode', 'trialMetaData.trialStatusCategory', 'trialMetaData.petitionFilingDate', 'regularPetitionerData.realPartyInInterestName', ], limit: 50, }); const list = trials.patentTrialProceedingDataBag ?? []; const first = list[0]?.trialNumber; const decisions = first ? await odp.ptab.decisions.byTrial(first) : { patentTrialDocumentDataBag: [] }; return { trials: list.map((t) => ({ trial: t.trialNumber, type: t.trialMetaData?.trialTypeCode, status: t.trialMetaData?.trialStatusCategory, petitioner: t.regularPetitionerData?.realPartyInInterestName, })), firstTrialDecisions: (decisions.patentTrialDocumentDataBag ?? []).map( (d) => ({ date: d.decisionData?.decisionIssueDate, type: d.decisionData?.decisionTypeCategory, outcome: d.decisionData?.trialOutcomeCategory, title: d.documentData?.documentTitleText, }), ), }; ``` ## Prosecution history From a patent number to its application, then its office actions and rejection grounds. ```js // One application's prosecution story: resolve a patent number, then pull its // office actions (current Office Action Search API) and the rejection grounds // raised in each. const found = await odp.patents.byPatentNumber('11,646,472', { fields: ['applicationNumberText', 'applicationMetaData.inventionTitle'], }); const app = found.patentFileWrapperDataBag?.[0]; if (!app) return { error: 'patent not found' }; const actions = await odp.officeActions.search({ q: `applicationNumberText:${app.applicationNumberText}`, fields: [ 'officeActionRecordIdentifier', 'documentCode', 'documentCodeDescriptionText', 'submissionDate', 'rejectionTypeBag', ], sort: 'submissionDate asc', limit: 50, }); return { application: app.applicationNumberText, title: app.applicationMetaData?.inventionTitle, officeActions: (actions.officeActionDataBag ?? []).map((a) => ({ date: a.submissionDate, code: a.documentCode, what: a.documentCodeDescriptionText, grounds: a.rejectionTypeBag, })), }; ``` ## Trademark status The status of several trademark cases in one request. ```js // TSDR: status of a few trademark applications in one request (multiStatus // takes up to 25). const r = await tsdr.multiStatus('sn', ['97123456', '97123457']); const marks = (r.transactionList ?? []).flatMap((t) => t.trademarks ?? []); return marks.map((t) => ({ serial: t.status?.serialNumber, mark: t.status?.markElement, status: t.status?.tm5StatusDesc, filed: t.status?.filingDate, registration: t.status?.usRegistrationNumber || null, classes: (t.gsList ?? []).map((g) => g.primeClassCode), })); ``` ## Tips * **Filter first.** USPTO serves one request at a time for each key, so calls queue. One well-filtered search is better than many lookups. * **Pass `fields` on every search.** Full patent and PTAB records are large. * **Start with a small `limit`**, 5 to 25. `count` gives the total. * **Use `facets`** to get counts without a page through the records. * **Return less.** A returned value over 256 KiB fails with `ResultTooLarge`. * **No matches is not an error.** A search with no matches returns `{ count: 0, …Bag: [] }`. The [SDK reference](/docs/reference/sdk/) lists every method.