API sandbox
An API sandbox makes it possible to build and run APIs. You can create your own versions of the examples provided on this site or you can build your own APIs.
API sandboxes are managed via two endpoint:
| /api-configs | Configuration of administrators and credentials of the API |
| /endpoint-configs | Implementation of the API per path and method |
Create an API sandbox
Copy the snippet below, replace {{EMAIL_ADDRESS}} with your email address and execute the command.
curl --location --request POST 'https://api.zuunr.com/api-configs' \
--header 'Content-Type: application/json' \
--data-raw '{
"admins":[{"email":"{{EMAIL_ADDRESS}}"}]
}'
The response will have status code 201 and the body will look something like:
{
"basePath": "/sb-3517215",
"admins": [
{
"authorizationHeader": "Basic cGV0ZXJAZXhhbXBsZS5jb206ZmFmZGQ0M2VjNjNhNDVkOWJhMDI1YWYxYzZiNDkyMWU=",
"email": "peter@example.com",
"password": "fafdd43ec63a45d9ba025af1c6b4921e"
}
]
}
Copy the values of basePath and authorizationHeader and save them i a safe place. You won’t be able to use your API sandbox without them. In the examples, basePath and authorizationHeader are referred to as {{SANDBOX_BASE_PATH}} and {{SANDBOX_AUTH}}
Implement an API endpoint
Copy the snippet below, replace {{SANDBOX_AUTH}} and {{SANDBOX_BASE_PATH}} and execute the command.
curl --location --request POST 'https://api.zuunr.com/endpoint-configs' \
--header 'Authorization: {{SANDBOX_AUTH}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "get",
"path": "{{SANDBOX_BASE_PATH}}/hello-world",
"processors": {
"onRequest": {
"Translator": {
"transformations": [
{
"/response": {
"body": {
"message": "Hello World!"
},
"status": 200
}
},
{
"/next": "sendResponse"
}
]
}
}
}
}'
The response will have status code 200.
Test the API endpoint
curl --location --request GET 'https://api.zuunr.com{{SANDBOX_BASE_PATH}}/hello-world'
The response will have status code 200 and the body will look like:
{
"message": "Hello World!"
}
Congratulations! You now have a working API sandbox. Let’s build APIs!
