Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I need to know how I can get the customer Id that Admin API provides you directly from Customer Id that FrontEnd API gives you back
For example, I m getting this customer Id in Admin API: 3174076055691
And inf frontend API this is something like: Z2lkOi8vc2hvcGlmeS9DdXN0b21lci8zMTc0MDc2MDU1Njkx
Thanks!
I think I found the solution:
Hi @Jalvarez2000 ,
What do you mean by frontend API? Can you be more specific. When a customer is signed in the customer ID can be accessed through Liquid syntax like so:
{{customer.id}}
If you want to access it else where in your application:
<script> var customer_id = {{customer.id}} this.yournamespace = customer_id </script>
Is there a specific reason you need to fetch the customer ID? If you had the customer ID then yes you can query Admin API and retrieve a single customer record.
Regards,
Sam
I mean Storefront API.
The issue I found is I wanted to match storefrontAPI customer Id and Admin API customer Id, as they were different.
I found the way here (C# code):
Hi @Jalvarez2000 ,
Storefront API uses GraphQL where Admin API uses REST. Hence why the IDs appear different.
Regards,
Sam
Hey Everyone!
Just chiming in here since this is a highly viewed thread. The IDs between the Storefront API and the Admin API do differ. As you've discovered, you can base64 encode the GID from the Admin API to get the Storefront API. This is due to being a public unauthenticated API - the Admin API can be accessed in both GraphQL and REST.
To learn more visit the Shopify Help Center or the Community Blog.