What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Expose the timeline through an API?

Expose the timeline through an API?

Michaël_G_
Shopify Partner
74 0 59

Hi Shopify :),

I can see in order now that there is a super nice timeline. However I didn't find any way for an app to interact with this timeline. It would allow some nice usages, especially here are some things that would be good:

* Being able to set a message.

* Being able to add a button that would return to the app and be signed by Shopify.

Have a nice day 🙂

Replies 88 (88)

Bob_Starr1
Shopify Staff (Retired)
27 0 9

Hello Michael!

Thanks for posting : ) At the present time our API doesn't provide access to the timeline.  However, we may open this up at some point in the future to allow developes to build integrations as you mentioned above.  No ETA on when this may happen but keep an eye on our API page here:

https://docs.shopify.com/api

If access to timeline becomes available you'll find details on it there.

Thanks!

To learn more visit the Shopify Help Center or the Community Blog.

Mehr
Visitor
1 0 0

Hi,

 

Can I in some way access the timeline through an API and add entries in the timeline?

mikemickymick
Tourist
5 0 1

This really needs to be a feature already, what's the hold up?

TJ_Biddle
Explorer
39 1 18

Wow - Was looking at other comments and I noticed they were from 3 years back... 

I stand corrected: It's been 6 YEARS since people wanted this feature and it's still lacking. Surely it's not that hard to implement

John
Shopify Partner
64 0 8

Another vote for seeing API for Timeline

Philip_Tolk
Tourist
5 0 8

Another vote for seeing API for Timeline

Paul_brooks
Shopify Partner
1 0 0

Another vote for seeing API for Timeline

Adam_Schaffer
Shopify Partner
29 0 3

Another vote for seeing API for Timeline

Jamie_D_
Shopify Staff (Retired)
533 1 92

Hey all,

This is something we are currently looking into.

Please subscribe to the API Announcement forums for upcoming announcements regarding new API functionality.

To learn more visit the Shopify Help Center or the Community Blog.

TJ_Biddle
Explorer
39 1 18

Are you though? Because it's been 6 years...

Adam_Robson
Shopify Partner
18 0 7

Yes, please add this to the API. Really surprised it's not available to developers!

Robin24
Excursionist
22 0 5

Another vote for this!

After convincing my gf to switch over to Shopify POS I just realised that orders taken using that app only store the email address (when a receipt is sent to the customer) in the timeline and thus it's impossible to get at from an automation viewpoint.

With the (awfully dated) old application, at least the sent customer receipts got placed in the sent items of her mailbox so I could write code to parse them, extract the customer email and add to our mailing list.

Currently though with the POS app, it's back to manually copy and pasting.

Fingers crossed sometime for this comes soon!

Jon57
Shopify Partner
4 0 1

Please add timeline access, especially the ability to post comments.

mikemickymick
Tourist
5 0 1

Another vote to expose the timeline via the API. Would be incredibly useful

HymnZ
Shopify Partner
399 6 49

You can read timeline comments using GraphQL API, but not write them.

We need both on REST as well.

My speciality lies in making Shopify work for your requirements, not the other way round. HMU on email: hymnz@outlook.com or on skype: hymnzzy

If you like my work, consider supporting me 🙂 https://www.buymeacoffee.com/hymnz
schnepple
Tourist
3 0 2

+1 to expose access to order comments through the REST API

mbesson
Shopify Partner
5 0 3

Another vote for seeing API for Timeline

CoppoG
Tourist
12 1 6

Another vote for seeing API for Timeline

jungshanlee
Visitor
1 0 2

Another vote for seeing API for Timeline

adhamdwikat
Tourist
6 0 1

is this  feature implemented or not yet  ? 

Luke30
Shopify Partner
13 0 1

+1 this would be amazing.

geo1
Visitor
1 0 0

Please add timeline access by API

Kevin-H
Shopify Partner
4 0 0

Another vote for seeing API for Timeline

GobBluth
Shopify Partner
7 0 0

+1 for Timeline API access ??

NilsA
Tourist
3 0 1

+1 for this. Would be really useful!

Philippe_Sigure
Shopify Partner
2 0 0

+1 for the timeline access ! I will use it in order to push message into our slack channels, so every one in my team will have the info, but it will be stored exactlly at the good place. 

 

Jono5
New Member
10 0 0

+1 please, planning to upload photos of my fulfilled packages using the API.

Jonathan-HA
Shopify Partner
336 26 107

+1 as well 🙂

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill

Sergio_Bayona
Tourist
4 0 2

+ 1 for Timeline API access.

Jamie_M1
New Member
14 0 0

+1

Sergey_Kravchen
Shopify Partner
5 0 0

+1

stu-boosterapps
Shopify Partner
34 0 6

+1

Stuart @ Booster Apps (https://apps.shopify.com/partners/booster-apps)

Craig_Mahy
Visitor
2 0 1

+1

Kenny8
Tourist
4 0 12

+1

Johan_Land
Shopify Partner
14 0 11

+1 really need

 

This has now been requested for two years. Fair to say that it would be good with a response from an admin on what the status of this is.

Johan_Land
Shopify Partner
14 0 11

Alright, so as this thread is successfully being ignored by Shopify I went ahead and researched this deeper.

There are two ways of achieving this:

 

Solution #1:

Shopify has in Beta a new API called GraphQL. The documentation is really sub par, but it is possible to get the timeline comments using this: https://help.shopify.com/api/graphql-admin-api/reference/object/commentevent

Below is a working Python Script for doing this:

`

import requests
import re
import sys
import json

#Getting the date out of an individual comment
def getdate(s):
    pattern = r'(?<=createdAt"\:").+?(?=\"})'
    date = re.findall(pattern, s)
    return date[0]

#Getting the message out of an individual comment
def getmessage(s):
    pattern = r'(?<=message"\:").+?(?=\"\,\"createdAt")'
    message = re.findall(pattern, s)
    return message[0]

def readsettings():
#Reading AUTH token (API Password in Shopify) and the name of your shop from settings.txt. First line should contain key, while the second one should contain name
    f = open("get_order_comments_settings.txt", "r")
    lines = f.read().splitlines()
    url = "https://" + lines[1] + ".myshopify.com/admin/api/graphql.json"
    auth = lines[0]
    #print("auth: " + auth + "'\n url: " + url)
    return (url, auth)

#Main function
def gql():
    
#You should use the script with 1 command-line argument (order id), you can get this order ID by going to the url of your order and copying the last part
    if len(sys.argv) < 1 or len(sys.argv) >2:
        print("Invalid usage of the command! \n Correct usage: python bot.py <order_id>")
        return
#Getting all the order events
    query = r'{ order(id: "gid://shopify/Product/' + sys.argv[1] + '"){events(first: 100){edges{node{__typename message createdAt  }}}}}'
    
#Getting settings
    (url, api_token) = readsettings()

#Commented out hard-coded values
    #url = r'https://tester35353.myshopify.com/admin/api/graphql.json'
    #api_token = "51d157d4ff8ef92bdd65e7011b52c14e"
    
    headers = {'X-Shopify-Access-Token': api_token, 'Content-Type' : "application/graphql"}

#posting the request to GraphiQL Shopify API
    r = requests.post(url=url, data=query, headers=headers)

#searching for the right events from the response
    pattern = r'typename":"CommentEvent".+?(?=\{)'
    
    found  = re.findall(pattern, r.text)

#basic error handling, should be expanded on/changed if you need to feed the output to another script
    if len(found) < 1:
        print("No matches, details: \n" + r.text)
    dictionary = {}
    index = 0
    
#forming a dictionary to dump into json
    for i in found:
        dictionary["Comment " + str(index)] = (getmessage(i), getdate(i))
        index+=1
        #print("message: " + getmessage(i))
        #print("date: " + getdate(i))

#printing out the result to STDOUT
    print(json.dumps(dictionary))
    #print("order id: " + sys.argv[1])

if __name__ == '__main__':
    gql()
`

 

Solution #2:

You can just crawl the shopify web front end and perform a login. Below is an UNVERIFIED solution to this. I paid a developer to do this before I created the solution above, and as such I haven't tested the code. Use at your own risk:

`

#sudo apt-get install python-pip
#sudo pip install selenium

from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import sys 
import json
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

vendor_name='jaipur09'         ########## Enter your vendor name                     
dict={}
order_id=sys.argv[1]
email = sys.argv[2]
password = sys.argv[3]


options = webdriver.ChromeOptions()
options.add_argument("headless")
browser=webdriver.Chrome(executable_path="/home/mukul/Downloads/chromedriver",chrome_options=options)

#login page
browser.get("https://"+vendor_name+".myshopify.com/admin/auth/login") 
time.sleep(3)
print("Logging In")
emailObj = browser.find_element_by_xpath('//*[@id="Login"]')
passwordObj = browser.find_element_by_xpath('//*[@id="Password"]')
emailObj.send_keys(email)
passwordObj.send_keys(password)
login_attempt = browser.find_element_by_xpath('//*[@id="LoginSubmit"]')
login_attempt.submit()

element = WebDriverWait(browser, 100).until(EC.presence_of_element_located((By.XPATH, '//*[@id="AppFrameNav"]/nav/div[2]/div/ul[1]/li[2]/a/span')))
print("LogIn done")

#order_id page
browser.get('https://'+vendor_name+'.myshopify.com/admin/draft_orders/'+str(order_id))
time.sleep(3)
print("Scraping data")

#extracting comments and time
comments=browser.find_elements(By.CLASS_NAME,'timeline__comment-body')
times=browser.find_elements(By.CLASS_NAME,'timeline__time-link') 

for num in range(0,len(comments)):
    comment=comments[num]
    time=times[num]
    dict['comment'+str(num+1)]=comment.text
    dict['time'+str(num+1)]=time.text

print (json.dumps(dict))

`

 

 

I have solution #1 in production and it's working like a charm.

 

Johan_Land
Shopify Partner
14 0 11

... and I'm back to this thread. Because now, I need to post to the timeline. And, I can't find any solution. Seems GraphiQL api doesn't support that either.

 

Please shopify?

KarlOffenberger
Shopify Partner
1873 184 903

In GraphQL for events.

query {
  order(id: "gid://shopify/Order/790544056435") {
    events(first:5, sortKey: CREATED_AT, reverse: true) {
      pageInfo {
        hasNextPage
        hasPreviousPage
      }
      edges {
        node {
          __typename
          id
          message
          createdAt
          appTitle
          attributeToApp
          attributeToUser
          criticalAlert
        }
        cursor
      }
    }
  }
}

More basic in REST

GET /admin/events.json?filter=Order

or for specific Order

GET /admin/orders/915566133363/events.json

There are some requests or queries that are buggy and some event types that don't seem to be retrievable via APIs, but it is there. Am I missing something?

colinlongworth
Shopify Partner
1 0 1

+1 

 

Badly needed endpoint.

Moshe_B
Shopify Partner
2 0 0

+ 1

ThetaLabs
Visitor
1 0 7

+1

 

3 years for a simple addition like this with no resolution is unacceptable for a paid product

Gregarican
Shopify Partner
1033 86 292

Agreed. Our business is looking to implement Shopify POS for our front-end. I've had to build some supplemental SQL DB tables to manage partial-payment transactions. In our world these would be layaways of on-hand items and special orders for getting items we don't stock. Using the API, I can port out the details and get at tight reporting, tracking, and analysis.

 

So far so good, although being able to track the status of these "special orders" would be more effective if I was able to interact with the comments timeline from the Rest API's Orders endpoint. 

Gregarican
Shopify Partner
1033 86 292

The only saving grace is that I can at least query this via the GraphQL API. See https://community.shopify.com/c/Shopify-APIs-SDKs/Using-the-order-timeline-on-the-admin-API/td-p/439... for details. Can't write to them, but this is better than nothing!

dphighland
Tourist
6 0 4

Wow, this is truly pathetic that it's not available. Even 4 years after requesting it! Hello!!!! Shopify!!! Anybody??

Gregarican
Shopify Partner
1033 86 292

Did you see my post just prior to yours? This data is exposed in the GraphQL API. You cannot add comments via an API, but you can pull the existing ones that were created in the GUI. If this doesn't suit your requirements then I hear you. Enhancements like these are really just building out what should be existing functionality in a standard cloud-based POS.

EgalitarianCo
Tourist
6 0 5

+1 

 

Add export ability for timeline to your standard customer data exports. Make it easy for Merchants to own their data!

CJWalker
Tourist
10 0 12

Another vote for seeing API for Timeline

sealcoating
Visitor
1 0 1

+1 

 

Add ability to export Timeline data as part of the standard Orders export function.

WebKutir
Shopify Partner
1 0 1

Another vote for seeing API for Timeline