# Returning latest meeting booked with Python custom script

**URL:** <https://community.hubspot.com/t/returning-latest-meeting-booked-with-python-custom-script/77333>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [March 16, 2023, 12:37pm UTC](https://community.hubspot.com/t/returning-latest-meeting-booked-with-python-custom-script/77333 "2023-03-16T12:37:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DPodraza](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@DPodraza](https://community.hubspot.com/u/DPodraza)\
**Post date:** [March 16, 2023, 12:37pm UTC](https://community.hubspot.com/t/returning-latest-meeting-booked-with-python-custom-script/77333/1 "2023-03-16T12:37:49Z")

</div>

Hello,

I would like to return latest meeting booked for customer so I could then change its status afterwards. With below code I was able to return booked meeting, however it is not ordered to show most recently booked.

```lia-code-sample
import hubspot
from pprint import pprint
from hubspot.crm.objects.meetings import ApiException

API_KEY = "xxx"
def main(event):
 # Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.

 client = hubspot.Client.create(access_token=API_KEY)

 try:

 api_response = client.crm.objects.meetings.basic_api.get_page(limit=1, archived=False)
 meeting_dict = api_response.results[0]
 pprint(api_response)
 meeting_id = meeting_dict.id

 except ApiException as e:
 print("Exception when calling basic_api->get_page: %s\n" % e)

 #email = event["inputFields"]["email"]
 # Return the output data that can be used in later actions in your workflow.
 return {
 "outputFields": {
 "meeting_id": meeting_id
 }
 }

```

Is there a method to order results of the query?

Regards,

Damian.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 17, 2023, 5:43pm UTC](https://community.hubspot.com/t/returning-latest-meeting-booked-with-python-custom-script/77333/2 "2023-03-17T17:43:58Z")

</div>

Hi, @DPodraza 👋 Thanks for reaching out. Hey @JBeatty @tominal, do you have any experience with the approach @DPodraza is taking?

One other place to investigate is utilizing the [Search API,](https://developers.hubspot.com/docs/api/crm/search#sort-search-results) which allows for adding a “sorts” rule to the request body. And I’ll defer to our Python experts in the community to take a look at your specific issue.

```lia-code-sample
{
 "sorts": [
 {
 "propertyName": "createdate",
 "direction": "DESCENDING"
 }
 ]
 }

```

Best,

Jaycee
