Getting started with the Graniitti API
To get started with the Graniitti API:
Setting up your Frosmo user account
All requests to the Graniitti API must be authenticated with an access token. You get your personal access token through your Frosmo user account, so you need to first set up the account, if not already set up. For more information, see Setting up user accounts.
Getting your personal access token
To get your personal access token:
-
In the Frosmo Control Panel, in the header, click your username, and select API Access.
-
In the Graniitti API section, click Create token.
-
Copy the token. It will not be shown on the page again.
You now have your personal access token for authenticating with the Graniitti API. For more information about the token, see Graniitti API authentication.
Do not make Graniitti API requests in client-side code that is accessible to parties you do not trust, as this will expose your token to them. Use the Graniitti API only in server-side code and in client-side code that is only accessible to parties you trust.
Getting the base URL for requests
The base URL for Graniitti API requests depends on your Frosmo Platform instance and the API version you're using.
To get the base URL for the latest version in your platform instance:
-
In the Frosmo Control Panel, in the header, click your username, and select API Access.
-
In the Graniitti API section, copy the base URL.
You now have the base URL for sending requests to the Graniitti API.
Testing your access
Now that you have your personal access token, test that it works correctly by making the following calls to the Graniitti API.
This guide uses cURL examples to illustrate API calls, so you can simply copy and paste the relevant code to your application, or you can run the cURL commands directly from the command line (provided you have cURL installed).
To test your access:
-
Retrieve your own user information by sending a GET request to
/users
with your first name and last name as query parameters. Add your token to the request using theAuthorization
header, and prefix the token with "Bearer" followed by a space.curl -X GET \
--header 'Authorization: Bearer <access\_token>' \
'https://<graniitti\_api\_domain>/v0/users?firstname=<your\_first\_name>&lastname=<your\_last\_name>'infoThe domain name in the above URL depends on your Frosmo Platform instance. To find out which domain name you need to use, see Getting the base URL for requests.
-
Create a new user by sending a POST request to
/users
with the user information passed as a JSON object.curl -X POST \
--header 'Authorization: Bearer <access\_token>' \
--header 'Content-Type: application/json' \
-d '{"firstname":"User","lastname":"User","email":"user.user@company.com","password":"8sKJ0688p!"}' \
'https://<graniitti\_api\_domain>/v0/users'Note the user ID in the response body.
-
Retrieve the user you just created by sending a GET request to
/users/<user_id>
. Use the user ID from the response to the POST request.curl -X GET \
--header 'Authorization: Bearer <access\_token>' \
'https://<graniitti\_api\_domain>/v0/users/<user\_id>' -
Delete the user by sending a DELETE request to
/users/<user_id>
. Use the user ID from the response to the POST request.curl -X DELETE \
--header 'Authorization: Bearer <access\_token>' \
'https://<graniitti\_api\_domain>/v0/users/<user\_id>'
Now that you have a working token, learn about the basics of the Graniitti API and its RESTful features.