REST API or GraphQL API?
Both the 4me GraphQL API and 4me REST API can be used to retrieve and update 4me data. Which one of both should you use in your integration?
Using the 4me GraphQL API is recommended to integrate with 4me. The 4me GraphQL API allows to create precise and flexible queries for the data you need to integrate with 4me, getting predictable results, offering greater efficiency and flexibility compared to what is possible with the 4me REST API.
The 4me REST API was the first API that was made available to access the 4me service, even before GraphQL became open sourced in 2015. The 4me 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 4me REST API and then resolving it with the 4me GraphQL API.
name of the 4me 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-4me-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-4me-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-4me-account: widget" -X GET "https://api.4me-demo.com/v1/account"
In GraphQL this query looks like: