REST API or GraphQL API?
Both the Xurrent GraphQL API and Xurrent REST API can be used to retrieve and update Xurrent data. Which one of both should you use in your integration?
Using the Xurrent GraphQL API is recommended to integrate with Xurrent. The Xurrent GraphQL API allows to create precise and flexible queries for the data you need to integrate with Xurrent, getting predictable results, offering greater efficiency and flexibility compared to what is possible with the Xurrent REST API.
The Xurrent REST API was the first API that was made available to access the Xurrent service, even before GraphQL became open sourced in 2015. The Xurrent REST API is still available for backward compatibility.
To see the difference in efficiency and flexibility in action, try the following exercise, first by resolving it with the Xurrent REST API and then resolving it with the Xurrent GraphQL API.
Exercise:
Query the name
of the Xurrent account to which the organization of the manager of me
belongs. Retrieve also the name of the manager and the name of the organization of the manager.
Don’t forget to add read rights on the me, person, organization and account record types to the scope of the personal access token.
First you need to query the me
object to get the id of the manager:
curl -X GET -i -H "Authorization: Bearer <personal-token>" -H "X-Xurrent-Account: widget" "https://api.4me-demo.com/v1/me"
Next you create a query to get the manager record with the name of the organization to which the manager belongs:
curl -i -H "Authorization: Bearer <oauth-token>" -H "X-Xurrent-account: widget" -X GET "https://api.4me-demo.com/v1/people/200"
And finally you can get the name of the account with the following REST API:
curl -i -H "Authorization: Bearer <oauth-token>" -H "X-Xurrent-account: widget" -X GET "https://api.4me-demo.com/v1/account"
In GraphQL this query looks like: