Filtering and Searching with Common Paper API
This guide will walk you through the process of filtering and searching agreement data using the Common Paper API. We will provide curl examples to demonstrate how to interact with the API.
Filtering Agreements
To filter agreements, you can utilize query parameters with the API endpoints.
Example: Filtering Agreements by Status
To filter agreements based on their status, you can use the following curl command:
Code
Replace YOUR_API_KEY with your actual API key.
In this example, the filter parameter is filter[status_eq]=signed, which filters agreements with a "signed" status. The _eq is the operator that stands for equals. There are a number of supported operators such as _gt (greater than), _not_eq (not equal), and _cont (contains). The full list can be found here.
Searching Agreements
To search for agreements containing specific keywords or matching specific conditions, use the ransack gem's search predicates in the query parameters.
Example: Searching Agreements with fuzzy matching
To search for agreements containing "gmail.com" in the recipient_email, use the following curl command:
Code
In this example, the filter parameter is filter[purpose_cont]=business, which searches for agreements with a purpose containing the word "business".
Code
Example: Searching Agreements by Date
Code
To search for agreements sent after a specific date, use the _gt operator like in the following curl command:
Code
Example: Searching Agreements by Multiple Conditions
Code
To search for agreements with a "signed" status and a gmail.com domain, use the following curl command:
Code
In this example, we combine two filter parameters: filter[status_eq]=signed and filter[recipient_email_cont]=gmail.com.
For more advanced queries and filtering options, refer to the Ransack documentation.