Endpoints
With Altogic, you can define your RESTful endpoints and associte them with your services. You can think of endpoint services as your cloud functions and define no-code services using the Designer and full-code functions using the Altogic CLI.
info
When the endpoint is called, the associated service (i.e., cloud function) is executed. The endpoint manager provides the methods to make POST, PUT, GET and DELETE requests to your app endpoints to run your cloud functions.
GET Request
You can use the get
method to make a GET request to your endpoint path.
Optionally, you can provide query string parameters or headers in this request.
- Javascript
- Dart
let orderId = "620949ee991edfba3ee644e7";
// Make a GET request to /orders/{orderId} endpoint
const { data, errors } = await altogic.endpoint.get(`/orders/${orderId}`);
final orderId = "620949ee991edfba3ee644e7";
// Make a GET request to /orders/{orderId} endpoint
final result = await altogic.endpoint.get("/orders/${orderId}").asMap();
info
- If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
- If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
- If the response returns no data back, then both errors and data marked as null.
Parameters
Here you can find parameters for the get
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | path | string | Yes | The path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile |
2 | queryParams | KeyValuePair | No | Query string parameters |
3 | headers | KeyValuePair | No | Request headers |
4 | resolveType | string | No | Type of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer" |
note
Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.
POST Request
You can use the post
method to make a POST request to your endpoint path.
Optionally, you can provide body, query string parameters or headers in this
request.
- Javascript
- Dart
let postId = "62094b43f7205e7d78082504";
// Make a POST request to /wallposts/{postId}/comments endpoint
const { data, errors } = await altogic.endpoint.post(`/wallposts/${postId}/comments`, {
userId: "620949ee991edfba3ee644e7",
comment:
"Awesome product. Would be better if you could add tagging people in comments.",
});
final postId = "62094b43f7205e7d78082504";
// Make a POST request to /wallposts/{postId}/comments endpoint
final result = await altogic.endpoint.post(
"/wallposts/${postId}/comments",
body: {
"userId": "620949ee991edfba3ee644e7",
"comment":
"Awesome product. Would be better if you could add tagging people in comments.",
})
.asMap();
info
- If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
- If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
- If the response returns no data back, then both errors and data marked as null.
Parameters
Here you can find parameters for post
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | path | string | Yes | The path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile |
2 | body | Object or FormData | No | Request body |
3 | queryParams | KeyValuePair | No | Query string parameters |
4 | headers | KeyValuePair | No | Request headers |
5 | resolveType | string | No | Type of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer" |
note
Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.
PUT Request
You can use the put
method to make a PUT request to your endpoint path.
Optionally, you can provide body, query string parameters or headers in this
request.
- Javascript
- Dart
let userId = "62094b734848b88ff50c2ab0";
// Make a PUT request to /users/{userId}/address
const { data, errors } = await altogic.endpoint.put(`/users/${userId}/address`, {
city: "Chicago",
street: "121 W Chestnut",
zipcode: "60610",
state: "IL",
country: "US",
});
final userId = "62094b734848b88ff50c2ab0";
// Make a PUT request to /users/{userId}/address
final result = await altogic.endpoint.put(
"/users/${userId}/address",
body: {
"city": "Chicago",
"street": "121 W Chestnut",
"zipcode": "60610",
"state": "IL",
"country": "US",
});
info
- If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
- If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
- If the response returns no data back, then both errors and data marked as null.
Parameters
Here you can find parameters for the put
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | path | string | Yes | The path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile |
2 | body | Object or FormData | No | Request body |
3 | queryParams | KeyValuePair | No | Query string parameters |
4 | headers | KeyValuePair | No | Request headers |
5 | resolveType | string | No | Type of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer" |
note
Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.
DELETE Request
You can use the delete
method to make a DELETE request to your endpoint path.
Optionally, you can provide body, query string parameters or headers in this
request.
- Javascript
- Dart
let postId = "62094b4dfcc106baba52c8ec";
let commentId = "62094b66fc475bdd5a2bfa48";
// Make a DELETE request to /wallposts/{postId}/comments/{commentId} endpoint
const { data, errors } = await altogic.endpoint.delete(
`/wallpost/${postId}/comments/${commentId}`
);
final postId = "62094b4dfcc106baba52c8ec";
final commentId = "62094b66fc475bdd5a2bfa48";
// Make a DELETE request to /wallposts/{postId}/comments/{commentId} endpoint
final result = await altogic.endpoint.delete(
"/wallpost/${postId}/comments/${commentId}"
).asMap();
info
- If errors occurred during the execution of the request then errors object is returned and the data is marked as null.
- If no errors occured then depending on the type of the request the data object holds a single JSON object, an array of json objects, plain text, Blob or ArrayBuffer and the errors object is marked as null.
- If the response returns no data back, then both errors and data marked as null.
Parameters
Here you can find parameters for the endpoint delete
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | path | string | Yes | The path of the endpoint. The endpoint path needs to start with a slash '/' character e.g., /users/profile |
2 | body | Object or FormData | No | Request body |
3 | queryParams | KeyValuePair | No | Query string parameters |
4 | headers | KeyValuePair | No | Request headers |
5 | resolveType | string | No | Type of data to return as a response of the request. By default response data is parsed to JSON. Possible values are "json" "text" "blob" "arraybuffer" |
note
Depending on the configuration of the endpoint, an active user session might be required (e.g., user needs to be logged in) to call this method.