Your first API with forms
This guide builds a simple API step by step: a data source, a project, then an endpoint that you test.
1. Add a data source
- In the left menu, click Data sources, then New Data Source.
- At the Select type step, choose Relational (SQL) or Document (NoSQL), then click Next.
- At the Select provider step, choose for example MongoDB or PostgreSQL.
- For MongoDB, also choose the Connection Mode:
- Free: a database hosted by Grizzly, great for trying things out; you only need to give it a name;
- Cloud: a cloud database (for example MongoDB Atlas), with its connection string;
- On-Premise: your own server (host, port, credentials).
- At the Fill connection step, fill in the requested information. For a direct connection: the Connection Name, the Database, the Host, the Port and, if the database requires authentication, the Username and Password. Click Test connection to check the settings, then Next.
- At the Review step, check the summary, then click Save (or Create Database for a free database).
To try it quickly
Choose MongoDB in Free mode: there is nothing to install.
2. Create a project
- In the menu, click Projects, then New Microservice (or Create your first project if you don't have any project yet).
- Select Project Type: choose REST API, then click Next.
- Project Details: give it a unique Project Name (unaccented letters, numbers, spaces and
_, for example "Inventory") and, if you wish, a Description. - Database Configuration: choose the data source created in step 1, then its Database.
- Review: check the information, then click Validate.
Grizzly creates the project with a first release, 1.0.0.
3. Add an endpoint
Open your project from the Projects page.
In the Endpoints section, the project already contains an
Untitledresource group. Use it, or create your own group with Add Resource Group, for exampleproducts.On this group, click Add Endpoint. The wizard guides you step by step:
- Endpoint Definition: the HTTP Method (
GET,POST,PUT,DELETE…), the Path, for example/products, and any Parameters (in the query, a header, the path or the body); - Execution Request: the collection or table, and whether the endpoint returns an object or an array;
- Responses: the possible response codes (
200,404…).
For this first endpoint, the other steps (Content Types, Functions, Documentation) can stay as they are.
- Endpoint Definition: the HTTP Method (
At the Summary step, check the endpoint, then click Create.
4. Test your API
- On the project page, the Runtime URL is the address of your API. Each endpoint is available at this address followed by its path.
- In the Endpoints section, click Test and validate to open the Swagger interface and call your endpoints from the browser.
- You can also call an endpoint with Postman or
curl, by adding its path to the runtime URL:
bash
curl https://<runtime-url>/productsWhat's next?
- Protect your API with roles: see Secure an API. Security is enabled when the project is created.
- Export your API's contract with Export OpenAPI contract (JSON or YAML).
- Share your project with your team with Share.
