Sign in to API Spark (http://restlet.com/products/apispark/#)
Create a GoogleSheet with following cols and rows:
id | question | total_options | choice_1 | choice_2 | choice_3 | choice_4 | choice_5 |
---|---|---|---|---|---|---|---|
1 | What is your favorite programming language ? | 5 | Javascript | Java | Ruby | C/C++ | Python |
1 What is your favorite programming language ? 5 Javascript Java Ruby C/C++ Python
Important: Rename the sheet to "question" as it will be used by APISpark to name the API endpoint.
In APISpark, create an Entity Store with
- name: Poll Questions
- type: Google Sheets Wrapper
- spreadsheet: choose the spreadsheet created in the previous section
Once your Entity Store is successfully created, click on the green Deploy button.
In APISpark, create an Entity Store with
- name: Poll Results
- type: Full stack
Once the Entity Store is created, let's create an entity:
- In the overview, click on the button Add
- Add the entity Vote
- Vote entity should be created with a default attribute named
id
representing its primary key. Click on theid
property to change its properties. Set Value policy to Specified at creation and type to Integer as follow:
- Then, click on the little plus signs of the Vote entity to add additional properties. We’ll create 5 properties for the (up to) 5 possible answers to our questions:
Once your Entity Store is successfully created and configured, click on the green Deploy button.
Create a Web API:
- type: Full stack
- name: Poll API
- domain: any name that doesn't collide with other participants (eg. your github username prefixed with pollworkshop)
Once created, go to the “Settings” tab, and click on “Add” in the “Imports” panel on the left side, so as to import your two data stores: the Google Sheets with our questions and choices, and the Entity Store for the votes collection:
When both data stores are imported, if you go back to the “Overview” pane of your API, you can see our resources available:
One last click on the Deploy button to make your API live!
You can now test your APIs. To do so, select an API under the Resources section of your WebAPI, an example of curl command will be displayed:
Open a terminal and run the curl command. You should get something like that:
[{"id":"1","question":"What is your favorite programming language ?",
"total_options":"5",
"answer_1":"Javascript",
"answer_2":"Java",
"answer_3":"Ruby",
"answer_4":"C/C++",
"answer_5":"Python"}]
We have created and deployed our backend APIs. To start implementing the client app, go to step-02.