Setting up the REST API
The sample REST API for our White Label AngryCat Companion App is available on a free Azure Web Service.
You can browse to it
Full source code for the REST API is available
We've used the following technologies to create the REST API
- AspNetCore as the REST API Framework
- Swagger / Swashbuckle to document the REST API.
- NSwag to generate our Xamarin / Visual Studio REST API Client.
- Bazinga.AspNetCore.Authentication.Basic to provide basic authentication
We've used basic Authentication to keep the sample simpler, however this is inherently insecure, so in the real world you might use something like OpenIddict to secure the REST API.
The REST API does not have a CMS, or backend database, it simulates the data returned through code. In the real world you might provide the REST API through a CMS, like OrchardCore and a multi-tenanted website so each character can have their own website as well as their own app. However that is outside the scope of this sample.
The REST API has a single endpoint
- https://live-white-api-theappspajamas.azurewebsites.net/api/v1/AngryCat
- Produces AngryCatResultDto
AngryCatResultDto
{ "info": { "weight": 0, "location": "string", "color": "string", "celebrityCrush": "string" }, "likes": [ { "detail": "string" } ], "dislikes": [ { "detail": "string" } ] }
The REST API has four accounts setup on it
- Test : test
- bear : NEb46BEq944Z9WKgJxvpCZa8Ckh578kR8WQ
- blue : ReNFRTEUWFYmhe9cfvmGkGwwp3V4trRDF9N
- fluffy : 4nNeqf3jFaVMJE9HpsTsd5mkAPdWtk3aPQc
The current API version number is 1