Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

How to Retrieve Subscription Details for Orders Using Shopify REST API

How to Retrieve Subscription Details for Orders Using Shopify REST API

user072319
Shopify Partner
131 0 17

Hello,

 

I'm importing orders for a store that sells products including subscription beauty products. I need to retrieve the subscription details for these orders using the Shopify REST API.

 

Could someone please guide me on how to access subscription information for orders through the REST API? Are there specific endpoints or fields I should be aware of for fetching these details?

 

Thank you in advance for your help!

Replies 2 (2)

Liam
Community Manager
3108 344 895

Hi - this may be easier to achieve with the GraphQL API rather than the REST API. There is subscriptionContract query on the GraphQL API which you could use to get info about a subscription contract that is associated with an order, it could look something like this: 

 

query GetSubscriptionContractDetails {
  subscriptionContract(id: "gid://shopify/SubscriptionContract/1234567890") {
    id
    nextBillingDate
    status
    deliveryPolicy {
      interval
      intervalCount
    }
    customer {
      id
      email
      displayName
    }
    lines(first: 50, reverse: true) {
      edges {
        node {
          productId
          currentPrice {
            amount
            currencyCode
          }
          quantity
          title
          variantTitle
        }
      }
    }
    orders(first: 1, reverse: true) {
      edges {
        node {
          id
        }
      }
    }
  }
}

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

user072319
Shopify Partner
131 0 17

Appreciate your response. 

 

I want the subscription details using REST API only. Is there any Shopify REST API available to get this details?

Thanks