Sample REST API Queries (Explanation)

This page shows some fun queries to illustrate what might be possible using the basics of the REST API to illustrate some powerful combinations. The following all feature the same query structure with field:value conditions connected with +:

  • https://tickets.yourvenue.org/api/v1/patrons?only=first_name+last_name+company&sort=last_name+first_name
    • retrieves first, last and company fields from the patrons endpoint and sort by last name, then first name
  • https://tickets.yourvenue.org/api/v1/patrons?only=first_name+last_name+company&sort=last_name+first_name&q=-last_name:smith
    • retrieves only first, last and company from the patrons endpoint and sorts by last name, then first name, then eliminates any patron with the last name smith from the list
  • https://tickets.yourvenue.org/api/v1/patrons?only=first_name+last_name+company&sort=last_name&q=last_name:smith
    • retrieves first, last and company from the patrons endpoint, sorts by last name, then eliminates any patron with the last name smith from the list
  • https://tickets.yourvenue.org/api/v1/patrons?only=first_name+last_name+company&sort=last_name&q=last_name:smith
    • retrieves first, last and company from the patrons endpoint, sorts by last name, only returns results for people called smith, and exports as JSON format
  • https://tickets.yourvenue.org/api/v1/carts?q=status_id:4&only=date_checkout+order_id+patron_id+total_cost+order_notes&sort=-date_checkout
    • gets a list of all checked-out shopping carts and sorts them in descending order by checkout date

API List of Ticket for an Event   Top

A List of Tickets for an Event
A List of Tickets for an Event

This shows a list of tickets purchased for an event, the people who bought it and the order total.

  • The endpoint is tickets since we need to be looking for tickets, and patrons, performances, events and orders are all related to the purchased ticket: https://tickets.yourvenue.org/api/v1/tickets?
  • The query is patron >0, order >0 and event 61: q=patron_id:>0+order_id:>0+event_id:[61]
  • The fields are: event title, performance series, performance date, patron id, name, order total and order balance: only=event.title+performance.series_code+performance.perform_datetime+patron.id+patron.first_name+patron.last_name+patron.formal_name+order.id+order.total_amount+order.balance

The full REST API query for this example is:

https://tickets.yourvenue.org/api/v1/tickets?q=patron_id:>0+order_id:>0+event_id:[61]&only=event.title+performance.series_code+performance.perform_datetime+patron.id+patron.first_name+patron.last_name+patron.formal_name+order.id+order.total_amount+order.balance

API List of Orders for an Event   Top

Summary tickets, grouped by order
Summary tickets, grouped by order

This is a summary of people buying tickets for an event when the purchasers are grouped by order.

  • The endpoint is tickets since we need to be looking for tickets, and patrons, performances, events and orders are all related to the purchased ticket: https://tickets.yourvenue.org/api/v1/tickets?
  • The query is patron >0, order >0 and event 61: q=patron_id:>0+order_id:>0+event_id:[61]
  • The fields that are grouped are: event title, performance series, performance date, patron id, name, and order id: group=event.title+performance.series_code+performance.perform_datetime+patron.id+patron.first_name+patron.last_name+patron.formal_name+order_id
  • However, some data that is repeated can best be shown if it is aggregated, namely the sum of ticket quantity and total cost and the minimum of total amount and order balance (we use the minimum to get the value once per order): agg=sum(quantity):ticket_count+sum(total_cost):ticket_total+min(order.total_amount):order_total+min(order.balance):order_balance

The full REST API query for this example is:

https://tickets.yourvenue.org/api/v1/tickets?q=patron_id:>0+order_id:>0+event_id:[61]&group=event.title+performance.series_code+performance.perform_datetime+patron.id+patron.first_name+patron.last_name+patron.formal_name+order_id&agg=sum(quantity):ticket_count+sum(total_cost):ticket_total+min(order.total_amount):order_total+min(order.balance):order_balance

API List of Primary Phone Numbers for a Patron   Top

Primary Phone Numbers & Locations
Primary Phone Numbers & Locations

This query generates a list of patron marketing information, such as their Primary Email Location Description (e.g. Work, Home, etc), Primary Phone Location (e.g. work, mobile, etc), Primary Email Address, Patron ID, First Name, Last Name, and Primary Phone Number.

The full REST API query for this example is:

https://tickets.yourvenue.org/api/v1/marketing?only=patron.id+patron.first_name+patron.last_name+primary_email_link.location.description+primary_email.contents+primary_phone_link.location.description+primary_phone.contents&q=-primary_email.contents:null+-primary_phone.contents:null