Skip to content

Commit 12dcd0f

Browse files
committed
feat: add new API doc
1 parent 9bf2118 commit 12dcd0f

18 files changed

Lines changed: 1175 additions & 1 deletion
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Deploy documentation"
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy-documentation:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.x
24+
25+
- name: Install MkDocs Material
26+
run: |
27+
pip install mkdocs-material mkdocs-static-i18n[material] mkdocs-open-in-new-tab
28+
29+
- name: Push documentation to gh-pages branch
30+
working-directory: documentation
31+
run: mkdocs gh-deploy

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ build/
88
*private_api_key.json
99
bin/
1010
obj/
11-
__pycache__/
11+
__pycache__/
12+
site/

documentation/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MkDocs Local Setup
2+
3+
This project uses [MkDocs](https://www.mkdocs.org/) with the following plugins:
4+
5+
- Material theme
6+
- Static i18n (internationalization)
7+
- Open links in new tab
8+
9+
---
10+
11+
## Prerequisites
12+
13+
Make sure you have:
14+
15+
- Python 3.x
16+
- pip (or pip3)
17+
18+
---
19+
20+
## Install dependencies
21+
22+
```bash
23+
pip install mkdocs-material mkdocs-static-i18n[material] mkdocs-open-in-new-tab
24+
```
25+
26+
## Running the documentation locally
27+
28+
```bash
29+
mkdocs serve
30+
```
31+
32+
Once running, open your browser at [http://127.0.0.1:8000](http://127.0.0.1:8000)
5.3 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
### Base URL
2+
3+
<code>
4+
https://api.forms-formulaires.alpha.canada.ca/v1/...
5+
</code>
6+
7+
8+
> _Note: You may need to use a cloud provider such as Microsoft Azure or Amazon Web Services (AWS), to be able to access the endpoint._
9+
10+
### How authentication works
11+
12+
The GC Forms API leverages an OAuth 2.0 Signed JSON Web Token ([JWT](https://jwt.io/)) flow with a self-hosted Identity provider (IDP), Zitadel, to establish machine-to-machine authentication in a safe and secure way for the API endpoint.
13+
14+
Authentication is done through an opaque token, with basic authorization handled via the user profile and the requested form ID. The OAuth server provides a short-lived access token that can be used to make API requests by verifying the client’s JWT that has been signed with a private key and includes their client ID. This access token is valid for 30 minutes.
15+
16+
The API requires authentication with a Government of Canada email, an associated **formID**, a JWT signed with a **Private key** and verified using a **Public key** with the IDP. This token contains a claim to specify the form ID from which it is associated.
17+
18+
### Integration examples
19+
20+
Once you’ve created a form, you can submit mock form submissions to simulate an active form and be able to test generating an access token.
21+
22+
Use these examples as a reference to generate access tokens in your preferred programming language:
23+
- [.NET / C#](https://github.com/cds-snc/forms-api/blob/main/examples/dotnet/AccessTokenGenerator.cs)
24+
- [Node.JS / Typescript](https://github.com/cds-snc/forms-api/blob/main/examples/nodejs/accessTokenGenerator.ts)
25+
- [Python](https://github.com/cds-snc/forms-api/blob/main/examples/python/access_token_generator.py)
26+
- [Bash /Curl](https://github.com/cds-snc/forms-api/blob/main/examples/bash/get_access_token.sh)
27+
28+
### Authorization header
29+
30+
Use this header for each API request to verify it’s you:
31+
<code>
32+
<br>
33+
<br> curl \
34+
<br> --request GET "$FORMS_URL" \
35+
<br> --header "Authorization: Bearer $ACCESS_TOKEN"
36+
</code>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Overview
2+
3+
The purpose of this API is to allow you to securely and reliably retrieve form submissions directly from an API endpoint. This should help alleviate the effort associated for very high volumes of form submissions. So, rather than having to manually download and sign off on the removal of responses to confirm their retrieval from the database, the API will automate the workflow with systems that talk to each other and exchange data.
4+
5+
### What you will need
6+
- A [GC Forms account](https://articles.alpha.canada.ca/forms-formulaires/)
7+
- A draft form (Unclassified, Protected A, or Protected B)
8+
- An API key (that you generate in Settings > API integration).
9+
- A few “mock” responses submitted to the form
10+
- A target system where you plan on receiving form submission data
11+
- Infrastructure development resources who can craft HTTP requests to reach the API. _No infrastructure development capabilities available? This first version of the API might not be ready for you just yet._
12+
13+
> **IMPORTANT: You must keep this API key secure as it is used to authenticate API requests and could be used to access protected data. Use encrypted email if you must share it with a developer team member to set up the integration.**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
We’re open to all questions and welcome any feedback you might have to help us improve. You can get in touch with our team directly with any questions or needs for technical support, by filling out the [Support form](https://forms-formulaires.alpha.canada.ca/en/support).
2+
3+
> Please include your name, email address, the form ID, response IDs (if relevant), and a description of the problem. We'll do our best to be in touch within 2 business days.

documentation/docs/en/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Welcome
2+
3+
Welcome to the technical documentation for the GC Forms application programming interface (API). This site is for developers who want to use the GC Forms API to retrieve form submission data programmatically into their department’s web application or back-office system.
4+
5+
Here you'll find how to set up an initial integration to securely retrieve form submissions. We appreciate your open and honest feedback to help us improve GC Forms and shape the future of this product.

0 commit comments

Comments
 (0)