How to
Get user data
Retrieve authenticated user profile information including address and preferences using Geins Merchant API
Prerequisites
- Merchant API key
- Bearer token (obtained from user authentication)
Learn how to obtain a Bearer token by following the Log in user guide.
Goal
- Get and display user data
Architecture at a glance
- Use
getUserquery → Retrieve user profile data - Include Bearer token in
Authorization: Bearer {token}header for authentication
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Get user profile information
Use the getUser query to retrieve the authenticated user's profile data:
Try it out in the GraphQL Playground using the query, headers and variables below.
Request example
query getUser(
$channelId: String
$languageId: String
$marketId: String
) {
getUser(
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
id
email
gender
customerType
newsletter
personalId
address {
firstName
lastName
addressLine1
addressLine2
city
state
country
zip
company
mobile
phone
}
}
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_BEARER_TOKEN}"
}
{
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_BEARER_TOKEN}" \
-d '{"query":"query getUser($channelId: String, $languageId: String, $marketId: String) { getUser(channelId: $channelId, languageId: $languageId, marketId: $marketId) { id email gender customerType newsletter personalId address { firstName lastName addressLine1 addressLine2 city state country zip company mobile phone } } }","variables":{"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
The
channelId, languageId, and marketId arguments are optional and can be left out to use default values.Response example
200 OKresponse.json
{
"data": {
"getUser": {
"id": 12345,
"email": "{USER_EMAIL}",
"gender": "WOMAN",
"customerType": "PERSON",
"newsletter": true,
"personalId": "19901231-1234",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"addressLine1": "456 Main Street",
"addressLine2": "Apartment 2B",
"city": "Stockholm",
"state": "Stockholm",
"country": "Sweden",
"zip": "11122",
"company": null,
"mobile": "+46 70 123 456 78",
"phone": "+46 8 123 456 78"
}
}
}
}
Multi-market support
The query supports optional parameters for multi-market configurations:
Common pitfalls
- Missing
Authorizationheader with Bearer token - the request will fail without authentication - Expired Bearer token - refresh the token if you receive authentication errors
Related
Change user passwordGet user ordersLog in userLog out userRefresh user tokenRegister userReset user passwordUse multi-market supportGetUser