# Use reporting endpoints > Build custom reports and dashboards with flexible query and statistics endpoints. Retrieve transactions, batches, customers, and aggregated data with powerful filtering and export to CSV or XLSX Although the PartnerHub and PayHub reporting tools allow partners and merchants to view reports, the reporting APIs offer more flexibility. For example,you may need to send daily settlement reporting details to their customers via an internal tool. Use the Payabli reporting APIs to get the data you need in the format you need it in. The *query* API allows you to retrieve records related to various objects in Payabli, like customers, vendors, batches, transactions, and more. The *statistics* API allows you to retrieve aggregated statistics for a certain period and mode, like total money out transactions, total money in transactions, number of new customers, total volume, and more. This guide explains how to use the query and stats endpoints. ## Build the request First, choose an endpoint. If you're testing, use the Sandbox endpoint. for your target environment. Make sure you use the right token for your selected environment. The API reference organizes query and statistic endpoints with their related object. For example, you can find all the reporting endpoints related to customers in the **Customers** section of the API reference. ### Parameters For a full list of available parameters, see the reference for the endpoint you choose. Most require at least an `orgId` or `entry`. Each endpoint may have other required fields. You can also use filters and conditions for most endpoints, so see [Filters and Conditions Reference](#filters-and-conditions-reference) for examples and help understanding them. #### Export formats Most query endpoints support an `exportFormat` parameter that allows you to export data directly from the query endpoint in CSV or XLSX format. When you include `exportFormat=csv` or `exportFormat=xlsx` in your request, the endpoint returns the data in the specified format instead of JSON. This includes endpoints for batches, batch details, customers, transactions, transfers, settlements, payouts, chargebacks, subscriptions, vendors, organizations, and more. For example, the batch query endpoints support export formats: * Organization level: `/Query/batches/org/{orgId}?exportFormat=csv` * Paypoint level: `/Query/batches/{entry}?exportFormat=xlsx` ### Example request Because there are infinite ways to build a request for one of the reporting endpoints, here are several example requests. Be sure to read the code comments for important context. ```curl Query list of transactions // This example queries transactions for the paypoint with entry ID e57ce00572. // It filters the results to include only transactions with a customerFirstname that contains "Mary" // with a transaction date of 05/08/2023, and limits the record count to 20. curl --request GET \ --url 'https://api-sandbox.payabli.com/api/Query/transactions/e57ce00572?parameters=customerFirstname%28ct%29%3DMary%26transactionDate%28eq%29%3D05%252F08%252F2023%26&limitRecord=20' \ --header "accept: application/json" \ --header "requestToken: " ``` ```curl Export batches as CSV // This example queries batches for organization 136 and exports the results as a CSV file. // You can combine exportFormat with filters and other parameters. curl --request GET \ --url 'https://api-sandbox.payabli.com/api/Query/batches/org/136?exportFormat=csv&limitRecord=100' \ --header "accept: text/csv" \ --header "requestToken: " ``` ```curl Get statistics for an org // This example gets the basic statistics grouped daily for // the year-to-date for the org with ID 136. curl --request GET \ --url https://api-sandbox.payabli.com/api/Statistic/basic/ytd/d/0/136 \ --header "accept: application/json" \ --header "requestToken: " ``` ## Example response A successful request returns a 200 response. By default, the response body is JSON. When you use the `exportFormat` parameter, the response is returned in the requested format (CSV or XLSX) instead of JSON. Response bodies vary by endpoint, so check the reference for the endpoint you're using for expected fields. ## Filters and conditions reference Each Query endpoint accepts a set of field identifiers and conditions that allow you to filter and select data in the API. Field identifiers and conditions are passed to the entrypoint path via parameters in the URL. The conditions are applied to the field in parentheses. The pattern is `fieldName(condition)=value` For example: `https://api.payabli.com/api/Query/transactions/entry?totalAmount(ge)=50` Here **totalAmount** is the field identifier to which you want to apply the comparison or condition. The condition is **(ge)**, which in this case is *greater or equal than*. The value base for the condition is **50**, so the expression above is filtering records with the value in field **totalAmount>=50**. Below you can see all the conventions for comparison you can use in the fields:
Condition Action
`eq` or empty equal to value
`gt` greater than value
`ge` greater or equal than value
`lt` lesser than value
`le` lesser or equal than value
`ne` not equal to value
`ct` contains value
`nct` not contains value
`in` include in array value (separated by "|")
`nin` not include in array value (separated by "|")
All the fields and conditions passed to the API entrypoint are inclusive, meaning that all conditions need to be satisfied to get the result set. Not all comparisons or conditions apply to all fields, refer to the API reference of each entrypoint to see the list of accepted fields and conditions. ### Date formats All dates must be in ISO 8601 format, for example `YYYY-MM-DDTHH:mm:ss`. #### Examples The filters are appended as query parameters when making an API request. These examples are URL-encoded, the unencoded filter is included with the definition.
/api/Query/customers/entry?customerZip%28eq%29%3D37615%26customerFirstname%28ct%29%3DMary
Unencoded filter: `customerZip(eq)=37615&customerFirstname(ct)=Mary`. This query returns the first 20 transactions with a customer ZIP code of 37615 and a customer first name that contains "Mary".
/api/Query/subscriptions/entry?frequency%28eg%29%3Dmonthly\&limitRecord=20
Unencoded filter: `frequency(eg)=monthly`. This query returns the first 20 subscriptions with a monthly frequency.
/api/Query/vendors/org/orgID?ein%3Dnull\&limitRecord=100
Unencoded filter: `ein(eq)=null`. This query returns the first 100 records with an empty EIN.
## Related resources See these related resources to help you get the most out of Payabli. * **[Query CLI app](/developers/platform-developer-query-cli)** - Set up and use Payabli's Query CLI app to run queries against your Payabli data