Graniitti API: Requests
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.
Learn about the basics of Graniitti API requests.
Base URL
The base URL for Graniitti API requests is https://<graniitti>/<version>
, where <graniitti>
is the Graniitti API domain name of your Frosmo Platform instance, and <version>
is 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.
For more information about Graniitti API versions, see Graniitti API: Versioning.
Request types
The API supports the following standard HTTP methods for manipulating resources.
Method | Action | Example |
---|---|---|
GET | Retrieve a resource or a collection of resources. |
|
POST | Create a new resource. |
|
PUT | Update a whole resource. |
|
PATCH | Update a portion of a resource. info This method is only used with company settings. |
|
DELETE | Delete a resource. |
|
Request headers
The API accepts the following headers in a request.
Header | Description | Allowed values |
---|---|---|
| Media type of the request body. This field is required for POST and PUT requests. |
|
| Access token for authenticating with the API. This field is required for all requests. For instructions on how to get the token, see Graniitti API authentication. |
|
For more information about the standard HTTP headers, see the header fields registry maintained by IANA.
Request body
For POST, PUT, and PATCH requests, the body must be in the JSON format. If the body is not valid JSON, or if the data model represented by the JSON is incorrect, the API returns a 400
status code in the response.
A single resource is represented as an object. A collection of resources is represented as an array of objects. The following example shows a request body containing a single resource object.
{
"firstname": "User",
"lastname": "User",
"email": "user.user@company.com",
"password": "8sKJ0688p!",
"role": "user"
}
Trimming
The API automatically strips the following characters from the beginning and end of all string values in the request body:
-
Carriage return (
\r
) -
New line (
\n
) -
NUL (
\0
) -
Space
-
Tab (
\t
) -
Vertical tab (
\x0B
)
The API uses the PHP trim()
function to strip the characters.
The following example shows a request body before and after trimming.
/* Request body sent to the Graniitti API */
{
"firstname": " User ",
"lastname": "User\n",
"email": "\t\tuser.user@company.com",
"password": "8sKJ0688p!",
"role": "user"
}
/* Request body trimmed by the Graniitti API */
{
"firstname": "User",
"lastname": "User",
"email": "user.user@company.com",
"password": "8sKJ0688p!",
"role": "user"
}
Query parameters
The API supports the following query parameters for GET requests. You can use the parameters to filter and otherwise process the results returned by the API.
Parameter | Description | Example |
---|---|---|
| Filter results based on resource field values. For more information, see Filtering with field values. |
|
| Replace the custom code with a placeholder text string when retrieving the full contents of a custom script with a For example, info The note When you use the If you want to get the latest contents with the changes, first deploy the custom script with a For more information about deploying the custom script, see Updating the custom script with the Graniitti API. |
|
| Select which fields are included in the response. For more information, see Selecting which fields to return. |
|
| Use Feed Item Query Language (FIQL) to define advanced results filtering. The For more information, see Filtering with FIQL. |
|
| Embed related resources in the response. For more information, see Embedding. |
|
| Specify the number of the page from which to return the results. Specifying this parameter enables pagination of results. info If you specify this parameter, the API returns the results only from the specified page. For example, if you set this parameter to By default, results are not paginated, and requests that do not use pagination are limited to 10 000 results. If a request finds more than 10 000 results, the request returns an error. In this case, to get the results, use pagination. For more information, see Paginating. |
|
| Specify the number of results to return per page. The default is 100 results. info This parameter has no effect unless you also specify the For more information, see Paginating. |
|
| Sort the results by one or more fields. For more information, see Sorting. |
|