Skip to content

Call an API ​

Once your endpoints are created, your API is ready to be called from any HTTP client: a web or mobile app, a script, Postman, curl… This page explains how to build a request.

The runtime URL ​

At the top of the project's page, the Runtime URL is your API's address.

To call an endpoint, add its path to the end of this URL:

EndpointURL to call
GET /productshttps://<runtime-url>/products
GET /products/{reference}https://<runtime-url>/products/PRD-001
POST /signinhttps://<runtime-url>/signin

The resource group name is not part of the URL: only the endpoint's path matters.

TIP

Copy the runtime URL from the project's page rather than rebuilding it by hand. The Test and validate button also gives the server URL and lets you call the endpoints from Swagger.

HTTP methods ​

Generated APIs answer the GET, POST, PUT and DELETE methods. These are the only supported methods. The endpoint form still shows PATCH, HEAD and OPTIONS, but a call with one of these methods is rejected (405 Method Not Allowed). To update data, use PUT.

Use the method declared on the endpoint: the same path can exist with several methods, for example GET /products to read and POST /products to add.

Parameters ​

The parameters declared on the endpoint are sent according to their location:

LocationExample
Path/products/{reference} is called with /products/PRD-001
Query/products?category=books
Headeran HTTP header named after the parameter

The value received replaces %name in the endpoint's query. For example, with the query {"reference": "%reference"}, the following call returns the product PRD-001:

bash
curl https://<runtime-url>/products/PRD-001

The request body ​

For POST and PUT, the only methods with a body accepted at runtime, send the data as JSON with the Content-Type: application/json header:

bash
curl -X POST https://<runtime-url>/products \
  -H "Content-Type: application/json" \
  -d '{"reference": "PRD-001", "name": "Notebook", "price": 12.5}'

Pagination ​

If Enable Pagination is checked on the endpoint, add two query parameters:

  • pageNumber: the page number, starting at 0;
  • pageSize: the number of items per page.
bash
curl "https://<runtime-url>/products?pageNumber=0&pageSize=20"

Both parameters are required. If one is missing, the API answers with an error, for example You need to provide a pageNumber and pageSize.

Call a secured endpoint ​

When the project's security is enabled, endpoints that are not public require a token (JWT). The Authentication Grizzly group provides the endpoints to get one.

  1. Sign in with POST /signin, sending the username and password:

    bash
    curl -X POST https://<runtime-url>/signin \
      -H "Content-Type: application/json" \
      -d '{"username": "alice", "password": "<password>"}'

    The response contains the token:

    json
    {"token": "eyJhbGciOi..."}
  2. Send this token in the Authorization header of each call, preceded by Bearer:

    bash
    curl https://<runtime-url>/orders \
      -H "Authorization: Bearer <token>"

By default, the token expires after one hour. Once it has expired, call /signin again to get a new one.

The token contains the user's roles. If none of their roles is among the endpoint's access roles, the call is refused (see Choose who can call an endpoint).

Create a user account

POST /signup creates a user of your API, with the user role. The body must contain username, password, email (a valid address), firstname, lastname and phone. The new account is inactive: until an administrator activates it, /signin answers Your account will be activated soon by the admin instead of returning a token.

WARNING

Never put a token or a password in the code of a public web page or in a URL: only send them in the request body or headers.

Supported databases ​

Grizzly runs your endpoints on the following databases:

FamilyDatabases
SQLMySQL, PostgreSQL, MariaDB, SQL Server
NoSQLMongoDB, Elasticsearch, Couchbase
AnalyticsBigQuery

The way to call the API is the same whatever the database: runtime URL, path, parameters and JSON.

Free plan limits ​

With the free plan, you can create:

ItemMaximum
APIs (projects)3
Data sources3
Flows3

See Free plan limits to find out what to do once a limit is reached.

What's next? ​

Grizzly API · CodeOnce Software